1 /* read.c - read a source file -
2 Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
3 2000 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 /* Set by the object-format or the target. */
57 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
58 #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
62 else if ((SIZE) >= 4) \
64 else if ((SIZE) >= 2) \
71 /* The NOP_OPCODE is for the alignment fill value.
72 * fill it a nop instruction so that the disassembler does not choke
76 #define NOP_OPCODE 0x00
79 char *input_line_pointer
; /*->next char of source file to parse. */
81 #if BITS_PER_CHAR != 8
82 /* The following table is indexed by[(char)] and will break if
83 a char does not have exactly 256 states (hopefully 0:255!)! */
88 /* The m88k unfortunately uses @ as a label beginner. */
93 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
98 /* The Delta 68k assembler permits % inside label names. */
103 /* The PowerPC Windows NT assemblers permits ? inside label names. */
112 /* The a29k assembler does not permits labels to start with $. */
117 /* The Delta 68k assembler permits ~ at start of label names. */
121 /* used by is_... macros. our ctype[] */
124 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
125 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
126 0, 0, 0, LEX_HASH
, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
127 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
128 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
129 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
130 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
131 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
132 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
133 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
134 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
135 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
136 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
137 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
138 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
139 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
145 * Out: 1 if this character ends a line.
148 char is_end_of_line
[256] =
151 99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, 99, Z_
, Z_
, /* @abcdefghijklmno */
153 99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, Z_
, Z_
, Z_
, /* @abcdefghijklmno */
155 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
157 Z_
,99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* _!"#$%&'()*+,-./ */
158 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* 0123456789:;<=>? */
160 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
161 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, Z_
, Z_
, /* 0123456789:;<=>? */
163 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
164 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
165 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
166 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
167 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
168 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
169 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
170 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
171 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
175 /* Functions private to this file. */
177 static char *buffer
; /* 1st char of each buffer of lines is here. */
178 static char *buffer_limit
; /*->1 + last char in buffer. */
180 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1 in the
181 tc-<CPU>.h file. See the "Porting GAS" section of the internals manual. */
182 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
184 static char *old_buffer
; /* JF a hack */
185 static char *old_input
;
186 static char *old_limit
;
188 /* Variables for handling include file directory table. */
190 char **include_dirs
; /* Table of pointers to directories to
191 search for .include's */
192 int include_dir_count
; /* How many are in the table */
193 int include_dir_maxlen
= 1;/* Length of longest in table */
195 #ifndef WORKING_DOT_WORD
196 struct broken_word
*broken_words
;
197 int new_broken_words
;
200 /* The current offset into the absolute section. We don't try to
201 build frags in the absolute section, since no data can be stored
202 there. We just keep track of the current offset. */
203 addressT abs_section_offset
;
205 /* If this line had an MRI style label, it is stored in this variable.
206 This is used by some of the MRI pseudo-ops. */
209 /* This global variable is used to support MRI common sections. We
210 translate such sections into a common symbol. This variable is
211 non-NULL when we are in an MRI common section. */
212 symbolS
*mri_common_symbol
;
214 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
215 need to align to an even byte boundary unless the next pseudo-op is
216 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
218 static int mri_pending_align
;
222 /* This variable is set to be non-zero if the next string we see might
223 be the name of the source file in DWARF debugging information. See
224 the comment in emit_expr for the format we look for. */
225 static int dwarf_file_string
;
229 static void cons_worker
PARAMS ((int, int));
230 static int scrub_from_string
PARAMS ((char *, int));
231 static void do_align
PARAMS ((int, char *, int, int));
232 static void s_align
PARAMS ((int, int));
233 static void s_lcomm_internal
PARAMS ((int, int));
234 static int hex_float
PARAMS ((int, char *));
235 static inline int sizeof_sleb128
PARAMS ((offsetT
));
236 static inline int sizeof_uleb128
PARAMS ((valueT
));
237 static inline int output_sleb128
PARAMS ((char *, offsetT
));
238 static inline int output_uleb128
PARAMS ((char *, valueT
));
239 static inline int output_big_sleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
240 static inline int output_big_uleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
241 static int output_big_leb128
PARAMS ((char *, LITTLENUM_TYPE
*, int, int));
242 static void do_org
PARAMS ((segT
, expressionS
*, int));
243 char *demand_copy_string
PARAMS ((int *lenP
));
244 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
245 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
246 static void pobegin
PARAMS ((void));
247 static int get_line_sb
PARAMS ((sb
*));
248 static void generate_file_debug
PARAMS ((void));
257 obj_read_begin_hook ();
259 /* Something close -- but not too close -- to a multiple of 1024.
260 The debugging malloc I'm using has 24 bytes of overhead. */
261 obstack_begin (¬es
, chunksize
);
262 obstack_begin (&cond_obstack
, chunksize
);
264 /* Use machine dependent syntax */
265 for (p
= line_separator_chars
; *p
; p
++)
266 is_end_of_line
[(unsigned char) *p
] = 1;
267 /* Use more. FIXME-SOMEDAY. */
273 /* set up pseudo-op tables */
275 static struct hash_control
*po_hash
;
277 static const pseudo_typeS potable
[] =
279 {"abort", s_abort
, 0},
280 {"align", s_align_ptwo
, 0},
281 {"ascii", stringer
, 0},
282 {"asciz", stringer
, 1},
283 {"balign", s_align_bytes
, 0},
284 {"balignw", s_align_bytes
, -2},
285 {"balignl", s_align_bytes
, -4},
289 {"common", s_mri_common
, 0},
290 {"common.s", s_mri_common
, 1},
294 {"dc.d", float_cons
, 'd'},
296 {"dc.s", float_cons
, 'f'},
298 {"dc.x", float_cons
, 'x'},
300 {"dcb.b", s_space
, 1},
301 {"dcb.d", s_float_space
, 'd'},
302 {"dcb.l", s_space
, 4},
303 {"dcb.s", s_float_space
, 'f'},
304 {"dcb.w", s_space
, 2},
305 {"dcb.x", s_float_space
, 'x'},
307 {"ds.b", s_space
, 1},
308 {"ds.d", s_space
, 8},
309 {"ds.l", s_space
, 4},
310 {"ds.p", s_space
, 12},
311 {"ds.s", s_space
, 4},
312 {"ds.w", s_space
, 2},
313 {"ds.x", s_space
, 12},
314 {"debug", s_ignore
, 0},
319 {"double", float_cons
, 'd'},
321 {"eject", listing_eject
, 0}, /* Formfeed listing */
323 {"elsec", s_else
, 0},
324 {"elseif", s_elseif
, (int) O_ne
},
326 {"endc", s_endif
, 0},
327 {"endfunc", s_func
, 1},
328 {"endif", s_endif
, 0},
333 {"exitm", s_mexit
, 0},
335 {"extern", s_ignore
, 0}, /* We treat all undef as ext */
336 {"appfile", s_app_file
, 1},
337 {"appline", s_app_line
, 0},
339 {"file", s_app_file
, 0},
341 {"float", float_cons
, 'f'},
342 {"format", s_ignore
, 0},
344 {"global", s_globl
, 0},
345 {"globl", s_globl
, 0},
347 {"if", s_if
, (int) O_ne
},
349 {"ifdef", s_ifdef
, 0},
350 {"ifeq", s_if
, (int) O_eq
},
351 {"ifeqs", s_ifeqs
, 0},
352 {"ifge", s_if
, (int) O_ge
},
353 {"ifgt", s_if
, (int) O_gt
},
354 {"ifle", s_if
, (int) O_le
},
355 {"iflt", s_if
, (int) O_lt
},
357 {"ifndef", s_ifdef
, 1},
358 {"ifne", s_if
, (int) O_ne
},
359 {"ifnes", s_ifeqs
, 1},
360 {"ifnotdef", s_ifdef
, 1},
361 {"include", s_include
, 0},
367 {"lcomm", s_lcomm
, 0},
368 {"lflags", listing_flags
, 0}, /* Listing flags */
369 {"linkonce", s_linkonce
, 0},
370 {"list", listing_list
, 1}, /* Turn listing on */
371 {"llen", listing_psize
, 1},
374 {"macro", s_macro
, 0},
375 {"mexit", s_mexit
, 0},
377 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
378 {"name", s_ignore
, 0},
379 {"noformat", s_ignore
, 0},
380 {"nolist", listing_list
, 0}, /* Turn listing off */
381 {"nopage", listing_nopage
, 0},
383 {"offset", s_struct
, 0},
385 {"p2align", s_align_ptwo
, 0},
386 {"p2alignw", s_align_ptwo
, -2},
387 {"p2alignl", s_align_ptwo
, -4},
388 {"page", listing_eject
, 0},
389 {"plen", listing_psize
, 0},
390 {"print", s_print
, 0},
391 {"psize", listing_psize
, 0}, /* set paper size */
392 {"purgem", s_purgem
, 0},
397 {"sbttl", listing_title
, 1}, /* Subtitle of listing */
402 {"single", float_cons
, 'f'},
404 {"space", s_space
, 0},
405 {"skip", s_space
, 0},
406 {"sleb128", s_leb128
, 1},
407 {"spc", s_ignore
, 0},
408 {"stabd", s_stab
, 'd'},
409 {"stabn", s_stab
, 'n'},
410 {"stabs", s_stab
, 's'},
411 {"string", stringer
, 1},
412 {"struct", s_struct
, 0},
416 /* This is for gcc to use. It's only just been added (2/94), so gcc
417 won't be able to use it for a while -- probably a year or more.
418 But once this has been released, check with gcc maintainers
419 before deleting it or even changing the spelling. */
420 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
421 /* If we're folding case -- done for some targets, not necessarily
422 all -- the above string in an input file will be converted to
423 this one. Match it either way... */
424 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
426 {"title", listing_title
, 0}, /* Listing title */
427 {"ttl", listing_title
, 0},
429 {"uleb128", s_leb128
, 0},
433 {"xdef", s_globl
, 0},
434 {"xref", s_ignore
, 0},
435 {"xstabs", s_xstab
, 's'},
437 {"zero", s_space
, 0},
438 {NULL
, NULL
, 0} /* end sentinel */
441 static int pop_override_ok
= 0;
442 static const char *pop_table_name
;
446 const pseudo_typeS
*table
;
449 const pseudo_typeS
*pop
;
450 for (pop
= table
; pop
->poc_name
; pop
++)
452 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
453 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
454 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
459 #ifndef md_pop_insert
460 #define md_pop_insert() pop_insert(md_pseudo_table)
463 #ifndef obj_pop_insert
464 #define obj_pop_insert() pop_insert(obj_pseudo_table)
470 po_hash
= hash_new ();
472 /* Do the target-specific pseudo ops. */
473 pop_table_name
= "md";
476 /* Now object specific. Skip any that were in the target table. */
477 pop_table_name
= "obj";
481 /* Now portable ones. Skip any that we've seen already. */
482 pop_table_name
= "standard";
483 pop_insert (potable
);
486 #define HANDLE_CONDITIONAL_ASSEMBLY() \
487 if (ignore_input ()) \
489 while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \
490 if (input_line_pointer == buffer_limit) \
496 /* This function is used when scrubbing the characters between #APP
499 static char *scrub_string
;
500 static char *scrub_string_end
;
503 scrub_from_string (buf
, buflen
)
509 copy
= scrub_string_end
- scrub_string
;
512 memcpy (buf
, scrub_string
, copy
);
513 scrub_string
+= copy
;
517 /* read_a_source_file()
519 * We read the file, putting things into a web that
520 * represents what we have been reading.
523 read_a_source_file (name
)
527 register char *s
; /* string of symbol, '\0' appended */
531 buffer
= input_scrub_new_file (name
);
534 listing_newline (NULL
);
535 register_dependency (name
);
537 /* Generate debugging information before we've read anything in to denote
538 this file as the "main" source file and not a subordinate one
539 (e.g. N_SO vs N_SOL in stabs). */
540 generate_file_debug ();
542 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
543 { /* We have another line to parse. */
544 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
545 contin
: /* JF this goto is my fault I admit it.
546 Someone brave please re-write the whole
547 input section here? Pleeze??? */
548 while (input_line_pointer
< buffer_limit
)
550 /* We have more of this buffer to parse. */
553 * We now have input_line_pointer->1st char of next line.
554 * If input_line_pointer [-1] == '\n' then we just
555 * scanned another line: so bump line counters.
557 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
559 #ifdef md_start_line_hook
560 md_start_line_hook ();
563 if (input_line_pointer
[-1] == '\n')
564 bump_line_counters ();
568 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
570 /* Text at the start of a line must be a label, we
571 run down and stick a colon in. */
572 if (is_name_beginner (*input_line_pointer
))
574 char *line_start
= input_line_pointer
;
579 HANDLE_CONDITIONAL_ASSEMBLY ();
581 c
= get_symbol_end ();
583 /* In MRI mode, the EQU and MACRO pseudoops must
584 be handled specially. */
588 char *rest
= input_line_pointer
+ 1;
592 if (*rest
== ' ' || *rest
== '\t')
594 if ((strncasecmp (rest
, "EQU", 3) == 0
595 || strncasecmp (rest
, "SET", 3) == 0)
596 && (rest
[3] == ' ' || rest
[3] == '\t'))
598 input_line_pointer
= rest
+ 3;
600 strncasecmp (rest
, "SET", 3) == 0);
603 if (strncasecmp (rest
, "MACRO", 5) == 0
606 || is_end_of_line
[(unsigned char) rest
[5]]))
610 /* In MRI mode, we need to handle the MACRO
611 pseudo-op specially: we don't want to put the
612 symbol in the symbol table. */
614 #ifdef TC_START_LABEL_WITHOUT_COLON
615 && TC_START_LABEL_WITHOUT_COLON(c
,
619 line_label
= colon (line_start
);
621 line_label
= symbol_create (line_start
,
626 *input_line_pointer
= c
;
628 input_line_pointer
++;
634 * We are at the begining of a line, or similar place.
635 * We expect a well-formed assembler statement.
636 * A "symbol-name:" is a statement.
638 * Depending on what compiler is used, the order of these tests
639 * may vary to catch most common case 1st.
640 * Each test is independent of all other tests at the (top) level.
641 * PLEASE make a compiler that doesn't use this assembler.
642 * It is crufty to waste a compiler's time encoding things for this
643 * assembler, which then wastes more time decoding it.
644 * (And communicating via (linear) files is silly!
645 * If you must pass stuff, please pass a tree!)
647 if ((c
= *input_line_pointer
++) == '\t'
652 c
= *input_line_pointer
++;
654 know (c
!= ' '); /* No further leading whitespace. */
657 /* If listing is on, and we are expanding a macro, then give
658 the listing code the contents of the expanded line. */
661 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
666 /* Find the end of the current expanded macro line. */
667 for (s
= input_line_pointer
-1; *s
; ++s
)
668 if (is_end_of_line
[(unsigned char) *s
])
671 /* Copy it for safe keeping. Also give an indication of
672 how much macro nesting is involved at this point. */
673 len
= s
- (input_line_pointer
-1);
674 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
675 memset (copy
, '>', macro_nest
);
676 copy
[macro_nest
] = ' ';
677 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
-1, len
);
678 copy
[macro_nest
+1+len
] = '\0';
680 /* Install the line with the listing facility. */
681 listing_newline (copy
);
684 listing_newline (NULL
);
689 * C is the 1st significant character.
690 * Input_line_pointer points after that character.
692 if (is_name_beginner (c
))
694 /* want user-defined label or pseudo/opcode */
695 HANDLE_CONDITIONAL_ASSEMBLY ();
697 s
= --input_line_pointer
;
698 c
= get_symbol_end (); /* name's delimiter */
700 * C is character after symbol.
701 * That character's place in the input line is now '\0'.
702 * S points to the beginning of the symbol.
703 * [In case of pseudo-op, s->'.'.]
704 * Input_line_pointer->'\0' where c was.
706 if (TC_START_LABEL(c
, input_line_pointer
))
710 char *rest
= input_line_pointer
+ 1;
712 /* In MRI mode, \tsym: set 0 is permitted. */
716 if (*rest
== ' ' || *rest
== '\t')
718 if ((strncasecmp (rest
, "EQU", 3) == 0
719 || strncasecmp (rest
, "SET", 3) == 0)
720 && (rest
[3] == ' ' || rest
[3] == '\t'))
722 input_line_pointer
= rest
+ 3;
728 line_label
= colon (s
); /* user-defined label */
729 *input_line_pointer
++ = ':'; /* Put ':' back for error messages' sake. */
730 /* Input_line_pointer->after ':'. */
736 || ((c
== ' ' || c
== '\t')
737 && input_line_pointer
[1] == '='
738 #ifdef TC_EQUAL_IN_INSN
739 && ! TC_EQUAL_IN_INSN (c
, input_line_pointer
)
744 demand_empty_rest_of_line ();
747 { /* expect pseudo-op or machine instruction */
750 #define IGNORE_OPCODE_CASE
751 #ifdef IGNORE_OPCODE_CASE
756 if (isupper ((unsigned char) *s2
))
763 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
765 /* The MRI assembler and the m88k use pseudo-ops
767 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
768 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
773 || (! flag_m68k_mri
&& *s
== '.'))
778 * WARNING: c has next char, which may be end-of-line.
779 * We lookup the pseudo-op table with s+1 because we
780 * already know that the pseudo-op begins with a '.'.
784 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
786 /* In MRI mode, we may need to insert an
787 automatic alignment directive. What a hack
789 if (mri_pending_align
791 || ! ((pop
->poc_handler
== cons
792 && pop
->poc_val
== 1)
793 || (pop
->poc_handler
== s_space
794 && pop
->poc_val
== 1)
795 #ifdef tc_conditional_pseudoop
796 || tc_conditional_pseudoop (pop
)
798 || pop
->poc_handler
== s_if
799 || pop
->poc_handler
== s_ifdef
800 || pop
->poc_handler
== s_ifc
801 || pop
->poc_handler
== s_ifeqs
802 || pop
->poc_handler
== s_else
803 || pop
->poc_handler
== s_endif
804 || pop
->poc_handler
== s_globl
805 || pop
->poc_handler
== s_ignore
)))
807 do_align (1, (char *) NULL
, 0, 0);
808 mri_pending_align
= 0;
809 if (line_label
!= NULL
)
811 symbol_set_frag (line_label
, frag_now
);
812 S_SET_VALUE (line_label
, frag_now_fix ());
816 /* Print the error msg now, while we still can */
819 as_bad (_("Unknown pseudo-op: `%s'"), s
);
820 *input_line_pointer
= c
;
825 /* Put it back for error messages etc. */
826 *input_line_pointer
= c
;
827 /* The following skip of whitespace is compulsory.
828 A well shaped space is sometimes all that separates
829 keyword from operands. */
830 if (c
== ' ' || c
== '\t')
831 input_line_pointer
++;
833 * Input_line is restored.
834 * Input_line_pointer->1st non-blank char
835 * after pseudo-operation.
837 (*pop
->poc_handler
) (pop
->poc_val
);
839 /* If that was .end, just get out now. */
840 if (pop
->poc_handler
== s_end
)
846 #ifdef QUOTES_IN_INSN
850 /* WARNING: c has char, which may be end-of-line. */
851 /* Also: input_line_pointer->`\0` where c was. */
852 *input_line_pointer
= c
;
853 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
855 #ifdef TC_EOL_IN_INSN
856 || TC_EOL_IN_INSN (input_line_pointer
)
860 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
862 #ifdef QUOTES_IN_INSN
865 else if (*input_line_pointer
== '"')
867 else if (*input_line_pointer
== '\\')
870 input_line_pointer
++;
873 c
= *input_line_pointer
;
874 *input_line_pointer
= '\0';
876 generate_lineno_debug ();
883 if (check_macro (s
, &out
, '\0', &err
))
887 *input_line_pointer
++ = c
;
888 input_scrub_include_sb (&out
,
892 input_scrub_next_buffer (&input_line_pointer
);
897 if (mri_pending_align
)
899 do_align (1, (char *) NULL
, 0, 0);
900 mri_pending_align
= 0;
901 if (line_label
!= NULL
)
903 symbol_set_frag (line_label
, frag_now
);
904 S_SET_VALUE (line_label
, frag_now_fix ());
908 md_assemble (s
); /* Assemble 1 instruction. */
910 *input_line_pointer
++ = c
;
912 /* We resume loop AFTER the end-of-line from
917 } /* if (is_name_beginner(c) */
920 /* Empty statement? */
921 if (is_end_of_line
[(unsigned char) c
])
924 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
925 && isdigit ((unsigned char) c
))
927 /* local label ("4:") */
928 char *backup
= input_line_pointer
;
930 HANDLE_CONDITIONAL_ASSEMBLY ();
934 while (isdigit ((unsigned char) *input_line_pointer
))
936 temp
= (temp
* 10) + *input_line_pointer
- '0';
937 ++input_line_pointer
;
938 } /* read the whole number */
940 if (LOCAL_LABELS_DOLLAR
941 && *input_line_pointer
== '$'
942 && *(input_line_pointer
+ 1) == ':')
944 input_line_pointer
+= 2;
946 if (dollar_label_defined (temp
))
948 as_fatal (_("label \"%d$\" redefined"), temp
);
951 define_dollar_label (temp
);
952 colon (dollar_label_name (temp
, 0));
957 && *input_line_pointer
++ == ':')
959 fb_label_instance_inc (temp
);
960 colon (fb_label_name (temp
, 0));
964 input_line_pointer
= backup
;
965 } /* local label ("4:") */
967 if (c
&& strchr (line_comment_chars
, c
))
968 { /* Its a comment. Better say APP or NO_APP */
972 unsigned int new_length
;
975 bump_line_counters ();
976 s
= input_line_pointer
;
977 if (strncmp (s
, "APP\n", 4))
978 continue; /* We ignore it */
981 ends
= strstr (s
, "#NO_APP\n");
985 unsigned int tmp_len
;
988 /* The end of the #APP wasn't in this buffer. We
989 keep reading in buffers until we find the #NO_APP
990 that goes with this #APP There is one. The specs
992 tmp_len
= buffer_limit
- s
;
993 tmp_buf
= xmalloc (tmp_len
+ 1);
994 memcpy (tmp_buf
, s
, tmp_len
);
997 new_tmp
= input_scrub_next_buffer (&buffer
);
1001 buffer_limit
= new_tmp
;
1002 input_line_pointer
= buffer
;
1003 ends
= strstr (buffer
, "#NO_APP\n");
1005 num
= ends
- buffer
;
1007 num
= buffer_limit
- buffer
;
1009 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
1010 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
1015 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1023 input_line_pointer
= ends
+ 8;
1027 scrub_string_end
= ends
;
1029 new_length
= ends
- s
;
1030 new_buf
= (char *) xmalloc (new_length
);
1037 space
= (new_buf
+ new_length
) - new_tmp
;
1038 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1046 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1047 new_tmp
= new_buf
+ new_length
;
1053 old_buffer
= buffer
;
1054 old_input
= input_line_pointer
;
1055 old_limit
= buffer_limit
;
1057 input_line_pointer
= new_buf
;
1058 buffer_limit
= new_tmp
;
1062 HANDLE_CONDITIONAL_ASSEMBLY ();
1064 #ifdef tc_unrecognized_line
1065 if (tc_unrecognized_line (c
))
1069 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
1070 input_line_pointer
--; /* Report unknown char as ignored. */
1071 ignore_rest_of_line ();
1072 } /* while (input_line_pointer<buffer_limit) */
1074 #ifdef md_after_pass_hook
1075 md_after_pass_hook ();
1081 bump_line_counters ();
1084 buffer
= old_buffer
;
1085 input_line_pointer
= old_input
;
1086 buffer_limit
= old_limit
;
1091 } /* while (more buffers to scan) */
1098 input_scrub_close (); /* Close the input file */
1101 /* For most MRI pseudo-ops, the line actually ends at the first
1102 nonquoted space. This function looks for that point, stuffs a null
1103 in, and sets *STOPCP to the character that used to be there, and
1104 returns the location.
1106 Until I hear otherwise, I am going to assume that this is only true
1107 for the m68k MRI assembler. */
1110 mri_comment_field (stopcp
)
1118 know (flag_m68k_mri
);
1120 for (s
= input_line_pointer
;
1121 ((! is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1126 inquote
= ! inquote
;
1136 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
1146 /* Skip to the end of an MRI comment field. */
1149 mri_comment_end (stop
, stopc
)
1155 input_line_pointer
= stop
;
1157 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1158 ++input_line_pointer
;
1163 int ignore ATTRIBUTE_UNUSED
;
1165 as_fatal (_(".abort detected. Abandoning ship."));
1168 /* Guts of .align directive. N is the power of two to which to align.
1169 FILL may be NULL, or it may point to the bytes of the fill pattern.
1170 LEN is the length of whatever FILL points to, if anything. MAX is
1171 the maximum number of characters to skip when doing the alignment,
1172 or 0 if there is no maximum. */
1175 do_align (n
, fill
, len
, max
)
1184 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1189 if (subseg_text_p (now_seg
))
1190 default_fill
= NOP_OPCODE
;
1193 fill
= &default_fill
;
1197 /* Only make a frag if we HAVE to. . . */
1198 if (n
!= 0 && !need_pass_2
)
1201 frag_align (n
, *fill
, max
);
1203 frag_align_pattern (n
, fill
, len
, max
);
1207 just_record_alignment
:
1210 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1213 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1214 (in bytes). A negative ARG is the negative of the length of the
1215 fill pattern. BYTES_P is non-zero if the alignment value should be
1216 interpreted as the byte boundary, rather than the power of 2. */
1219 s_align (arg
, bytes_p
)
1223 register unsigned int align
;
1231 stop
= mri_comment_field (&stopc
);
1233 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1238 align
= arg
; /* Default value from pseudo-op table */
1242 align
= get_absolute_expression ();
1248 /* Convert to a power of 2. */
1253 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1256 as_bad (_("Alignment not a power of 2"));
1264 as_bad (_("Alignment too large: %u assumed"), align
);
1267 if (*input_line_pointer
!= ',')
1274 ++input_line_pointer
;
1275 if (*input_line_pointer
== ',')
1279 fill
= get_absolute_expression ();
1284 if (*input_line_pointer
!= ',')
1288 ++input_line_pointer
;
1289 max
= get_absolute_expression ();
1296 as_warn (_("expected fill pattern missing"));
1297 do_align (align
, (char *) NULL
, 0, max
);
1312 do_align (align
, &fill_char
, fill_len
, max
);
1318 if ((size_t) fill_len
> sizeof ab
)
1320 md_number_to_chars (ab
, fill
, fill_len
);
1321 do_align (align
, ab
, fill_len
, max
);
1325 demand_empty_rest_of_line ();
1328 mri_comment_end (stop
, stopc
);
1331 /* Handle the .align pseudo-op on machines where ".align 4" means
1332 align to a 4 byte boundary. */
1341 /* Handle the .align pseudo-op on machines where ".align 4" means align
1342 to a 2**4 boundary. */
1353 int ignore ATTRIBUTE_UNUSED
;
1355 register char *name
;
1359 register symbolS
*symbolP
;
1364 stop
= mri_comment_field (&stopc
);
1366 name
= input_line_pointer
;
1367 c
= get_symbol_end ();
1368 /* just after name is now '\0' */
1369 p
= input_line_pointer
;
1372 if (*input_line_pointer
!= ',')
1374 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1375 ignore_rest_of_line ();
1377 mri_comment_end (stop
, stopc
);
1380 input_line_pointer
++; /* skip ',' */
1381 if ((temp
= get_absolute_expression ()) < 0)
1383 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
1384 ignore_rest_of_line ();
1386 mri_comment_end (stop
, stopc
);
1390 symbolP
= symbol_find_or_make (name
);
1392 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
1394 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1395 S_GET_NAME (symbolP
));
1396 ignore_rest_of_line ();
1398 mri_comment_end (stop
, stopc
);
1401 if (S_GET_VALUE (symbolP
))
1403 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1404 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
1405 S_GET_NAME (symbolP
),
1406 (long) S_GET_VALUE (symbolP
),
1411 S_SET_VALUE (symbolP
, (valueT
) temp
);
1412 S_SET_EXTERNAL (symbolP
);
1416 extern int flag_one
;
1417 if ( (!temp
) || !flag_one
)
1418 S_GET_OTHER(symbolP
) = const_flag
;
1420 #endif /* not OBJ_VMS */
1421 know (symbolP
->sy_frag
== &zero_address_frag
);
1423 demand_empty_rest_of_line ();
1426 mri_comment_end (stop
, stopc
);
1429 /* The MRI COMMON pseudo-op. We handle this by creating a common
1430 symbol with the appropriate name. We make s_space do the right
1431 thing by increasing the size. */
1434 s_mri_common (small
)
1435 int small ATTRIBUTE_UNUSED
;
1451 stop
= mri_comment_field (&stopc
);
1455 name
= input_line_pointer
;
1456 if (! isdigit ((unsigned char) *name
))
1457 c
= get_symbol_end ();
1462 ++input_line_pointer
;
1464 while (isdigit ((unsigned char) *input_line_pointer
));
1465 c
= *input_line_pointer
;
1466 *input_line_pointer
= '\0';
1468 if (line_label
!= NULL
)
1470 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1471 + (input_line_pointer
- name
)
1473 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1478 sym
= symbol_find_or_make (name
);
1479 *input_line_pointer
= c
;
1483 if (*input_line_pointer
!= ',')
1487 ++input_line_pointer
;
1488 align
= get_absolute_expression ();
1491 if (S_IS_DEFINED (sym
) && ! S_IS_COMMON (sym
))
1493 as_bad (_("attempt to re-define symbol `%s'"), S_GET_NAME (sym
));
1494 ignore_rest_of_line ();
1495 mri_comment_end (stop
, stopc
);
1499 S_SET_EXTERNAL (sym
);
1500 mri_common_symbol
= sym
;
1504 S_SET_ALIGN (sym
, align
);
1507 if (line_label
!= NULL
)
1510 exp
.X_op
= O_symbol
;
1511 exp
.X_add_symbol
= sym
;
1512 exp
.X_add_number
= 0;
1513 symbol_set_value_expression (line_label
, &exp
);
1514 symbol_set_frag (line_label
, &zero_address_frag
);
1515 S_SET_SEGMENT (line_label
, expr_section
);
1518 /* FIXME: We just ignore the small argument, which distinguishes
1519 COMMON and COMMON.S. I don't know what we can do about it. */
1521 /* Ignore the type and hptype. */
1522 if (*input_line_pointer
== ',')
1523 input_line_pointer
+= 2;
1524 if (*input_line_pointer
== ',')
1525 input_line_pointer
+= 2;
1527 demand_empty_rest_of_line ();
1529 mri_comment_end (stop
, stopc
);
1534 int ignore ATTRIBUTE_UNUSED
;
1539 temp
= get_absolute_expression ();
1540 if (flag_readonly_data_in_text
)
1542 section
= text_section
;
1546 section
= data_section
;
1548 subseg_set (section
, (subsegT
) temp
);
1553 demand_empty_rest_of_line ();
1556 /* Handle the .appfile pseudo-op. This is automatically generated by
1557 do_scrub_chars when a preprocessor # line comment is seen with a
1558 file name. This default definition may be overridden by the object
1559 or CPU specific pseudo-ops. This function is also the default
1560 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1564 s_app_file (appfile
)
1570 /* Some assemblers tolerate immediately following '"' */
1571 if ((s
= demand_copy_string (&length
)) != 0)
1573 /* If this is a fake .appfile, a fake newline was inserted into
1574 the buffer. Passing -2 to new_logical_line tells it to
1577 = (! new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1579 /* In MRI mode, the preprocessor may have inserted an extraneous
1582 && *input_line_pointer
== '\''
1583 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1584 ++input_line_pointer
;
1586 demand_empty_rest_of_line ();
1591 listing_source_file (s
);
1593 register_dependency (s
);
1601 /* Handle the .appline pseudo-op. This is automatically generated by
1602 do_scrub_chars when a preprocessor # line comment is seen. This
1603 default definition may be overridden by the object or CPU specific
1608 int ignore ATTRIBUTE_UNUSED
;
1612 /* The given number is that of the next line. */
1613 l
= get_absolute_expression () - 1;
1615 /* Some of the back ends can't deal with non-positive line numbers.
1616 Besides, it's silly. */
1617 as_warn (_("Line numbers must be positive; line number %d rejected."), l
+1);
1620 new_logical_line ((char *) NULL
, l
);
1623 listing_source_line (l
);
1626 demand_empty_rest_of_line ();
1629 /* Handle the .end pseudo-op. Actually, the real work is done in
1630 read_a_source_file. */
1634 int ignore ATTRIBUTE_UNUSED
;
1638 /* The MRI assembler permits the start symbol to follow .end,
1639 but we don't support that. */
1641 if (! is_end_of_line
[(unsigned char) *input_line_pointer
]
1642 && *input_line_pointer
!= '*'
1643 && *input_line_pointer
!= '!')
1644 as_warn (_("start address not supported"));
1648 /* Handle the .err pseudo-op. */
1652 int ignore ATTRIBUTE_UNUSED
;
1654 as_bad (_(".err encountered"));
1655 demand_empty_rest_of_line ();
1658 /* Handle the MRI fail pseudo-op. */
1662 int ignore ATTRIBUTE_UNUSED
;
1669 stop
= mri_comment_field (&stopc
);
1671 temp
= get_absolute_expression ();
1673 as_warn (_(".fail %ld encountered"), (long) temp
);
1675 as_bad (_(".fail %ld encountered"), (long) temp
);
1677 demand_empty_rest_of_line ();
1680 mri_comment_end (stop
, stopc
);
1685 int ignore ATTRIBUTE_UNUSED
;
1687 expressionS rep_exp
;
1689 register long fill
= 0;
1692 #ifdef md_flush_pending_output
1693 md_flush_pending_output ();
1696 get_known_segmented_expression (&rep_exp
);
1697 if (*input_line_pointer
== ',')
1699 input_line_pointer
++;
1700 size
= get_absolute_expression ();
1701 if (*input_line_pointer
== ',')
1703 input_line_pointer
++;
1704 fill
= get_absolute_expression ();
1708 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1709 #define BSD_FILL_SIZE_CROCK_8 (8)
1710 if (size
> BSD_FILL_SIZE_CROCK_8
)
1712 as_warn (_(".fill size clamped to %d."), BSD_FILL_SIZE_CROCK_8
);
1713 size
= BSD_FILL_SIZE_CROCK_8
;
1717 as_warn (_("Size negative: .fill ignored."));
1720 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1722 if (rep_exp
.X_add_number
< 0)
1723 as_warn (_("Repeat < 0, .fill ignored"));
1727 if (size
&& !need_pass_2
)
1729 if (rep_exp
.X_op
== O_constant
)
1731 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1732 (relax_substateT
) 0, (symbolS
*) 0,
1733 (offsetT
) rep_exp
.X_add_number
,
1738 /* We don't have a constant repeat count, so we can't use
1739 rs_fill. We can get the same results out of rs_space,
1740 but its argument is in bytes, so we must multiply the
1741 repeat count by size. */
1744 rep_sym
= make_expr_symbol (&rep_exp
);
1747 expressionS size_exp
;
1748 size_exp
.X_op
= O_constant
;
1749 size_exp
.X_add_number
= size
;
1751 rep_exp
.X_op
= O_multiply
;
1752 rep_exp
.X_add_symbol
= rep_sym
;
1753 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1754 rep_exp
.X_add_number
= 0;
1755 rep_sym
= make_expr_symbol (&rep_exp
);
1758 p
= frag_var (rs_space
, (int) size
, (int) size
,
1759 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1761 memset (p
, 0, (unsigned int) size
);
1762 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1763 * flavoured AS. The following bizzare behaviour is to be
1764 * compatible with above. I guess they tried to take up to 8
1765 * bytes from a 4-byte expression and they forgot to sign
1766 * extend. Un*x Sux. */
1767 #define BSD_FILL_SIZE_CROCK_4 (4)
1768 md_number_to_chars (p
, (valueT
) fill
,
1769 (size
> BSD_FILL_SIZE_CROCK_4
1770 ? BSD_FILL_SIZE_CROCK_4
1772 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1773 * but emits no error message because it seems a legal thing to do.
1774 * It is a degenerate case of .fill but could be emitted by a compiler.
1777 demand_empty_rest_of_line ();
1782 int ignore ATTRIBUTE_UNUSED
;
1791 stop
= mri_comment_field (&stopc
);
1795 name
= input_line_pointer
;
1796 c
= get_symbol_end ();
1797 symbolP
= symbol_find_or_make (name
);
1798 S_SET_EXTERNAL (symbolP
);
1800 *input_line_pointer
= c
;
1802 c
= *input_line_pointer
;
1805 input_line_pointer
++;
1807 if (*input_line_pointer
== '\n')
1813 demand_empty_rest_of_line ();
1816 mri_comment_end (stop
, stopc
);
1819 /* Handle the MRI IRP and IRPC pseudo-ops. */
1831 as_where (&file
, &line
);
1834 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1835 sb_add_char (&s
, *input_line_pointer
++);
1839 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1841 as_bad_where (file
, line
, "%s", err
);
1845 input_scrub_include_sb (&out
, input_line_pointer
);
1847 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1850 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1851 the section to only be linked once. However, this is not supported
1852 by most object file formats. This takes an optional argument,
1853 which is what to do about duplicates. */
1857 int ignore ATTRIBUTE_UNUSED
;
1859 enum linkonce_type type
;
1863 type
= LINKONCE_DISCARD
;
1865 if (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1870 s
= input_line_pointer
;
1871 c
= get_symbol_end ();
1872 if (strcasecmp (s
, "discard") == 0)
1873 type
= LINKONCE_DISCARD
;
1874 else if (strcasecmp (s
, "one_only") == 0)
1875 type
= LINKONCE_ONE_ONLY
;
1876 else if (strcasecmp (s
, "same_size") == 0)
1877 type
= LINKONCE_SAME_SIZE
;
1878 else if (strcasecmp (s
, "same_contents") == 0)
1879 type
= LINKONCE_SAME_CONTENTS
;
1881 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1883 *input_line_pointer
= c
;
1886 #ifdef obj_handle_link_once
1887 obj_handle_link_once (type
);
1888 #else /* ! defined (obj_handle_link_once) */
1889 #ifdef BFD_ASSEMBLER
1893 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1894 as_warn (_(".linkonce is not supported for this object file format"));
1896 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1897 flags
|= SEC_LINK_ONCE
;
1902 case LINKONCE_DISCARD
:
1903 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1905 case LINKONCE_ONE_ONLY
:
1906 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1908 case LINKONCE_SAME_SIZE
:
1909 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1911 case LINKONCE_SAME_CONTENTS
:
1912 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1915 if (! bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1916 as_bad (_("bfd_set_section_flags: %s"),
1917 bfd_errmsg (bfd_get_error ()));
1919 #else /* ! defined (BFD_ASSEMBLER) */
1920 as_warn (_(".linkonce is not supported for this object file format"));
1921 #endif /* ! defined (BFD_ASSEMBLER) */
1922 #endif /* ! defined (obj_handle_link_once) */
1924 demand_empty_rest_of_line ();
1928 s_lcomm_internal (needs_align
, bytes_p
)
1929 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1930 (alignment); 0 if it was an ".lcomm" (2 args only) */
1932 /* 1 if the alignment value should be interpreted as the byte boundary,
1933 rather than the power of 2. */
1936 register char *name
;
1940 register symbolS
*symbolP
;
1941 segT current_seg
= now_seg
;
1942 subsegT current_subseg
= now_subseg
;
1943 const int max_alignment
= 15;
1945 segT bss_seg
= bss_section
;
1947 name
= input_line_pointer
;
1948 c
= get_symbol_end ();
1949 p
= input_line_pointer
;
1953 /* Accept an optional comma after the name. The comma used to be
1954 required, but Irix 5 cc does not generate it. */
1955 if (*input_line_pointer
== ',')
1957 ++input_line_pointer
;
1961 if (*input_line_pointer
== '\n')
1963 as_bad (_("Missing size expression"));
1967 if ((temp
= get_absolute_expression ()) < 0)
1969 as_warn (_("BSS length (%d.) <0! Ignored."), temp
);
1970 ignore_rest_of_line ();
1974 #if defined (TC_MIPS) || defined (TC_ALPHA)
1975 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1976 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1978 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1979 if (temp
<= bfd_get_gp_size (stdoutput
))
1981 bss_seg
= subseg_new (".sbss", 1);
1982 seg_info (bss_seg
)->bss
= 1;
1983 #ifdef BFD_ASSEMBLER
1984 if (! bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1985 as_warn (_("error setting flags for \".sbss\": %s"),
1986 bfd_errmsg (bfd_get_error ()));
1994 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
1996 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
1998 record_alignment(bss_seg
, align
);
2005 if (*input_line_pointer
!= ',')
2007 as_bad (_("Expected comma after size"));
2008 ignore_rest_of_line ();
2011 input_line_pointer
++;
2013 if (*input_line_pointer
== '\n')
2015 as_bad (_("Missing alignment"));
2018 align
= get_absolute_expression ();
2021 /* Convert to a power of 2. */
2026 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2029 as_bad (_("Alignment not a power of 2"));
2033 if (align
> max_alignment
)
2035 align
= max_alignment
;
2036 as_warn (_("Alignment too large: %d. assumed."), align
);
2041 as_warn (_("Alignment negative. 0 assumed."));
2043 record_alignment (bss_seg
, align
);
2044 } /* if needs align */
2047 /* Assume some objects may require alignment on some systems. */
2048 #if defined (TC_ALPHA) && ! defined (VMS)
2051 align
= ffs (temp
) - 1;
2052 if (temp
% (1 << align
))
2059 symbolP
= symbol_find_or_make (name
);
2063 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2064 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2065 #ifdef BFD_ASSEMBLER
2066 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2067 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2069 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2072 (S_GET_SEGMENT (symbolP
) == bss_seg
2073 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2077 subseg_set (bss_seg
, 1);
2080 frag_align (align
, 0, 0);
2081 /* detach from old frag */
2082 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2083 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2085 symbol_set_frag (symbolP
, frag_now
);
2086 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
2087 (offsetT
) temp
, (char *) 0);
2090 S_SET_SEGMENT (symbolP
, bss_seg
);
2093 /* The symbol may already have been created with a preceding
2094 ".globl" directive -- be careful not to step on storage class
2095 in that case. Otherwise, set it to static. */
2096 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2098 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2100 #endif /* OBJ_COFF */
2103 S_SET_SIZE (symbolP
, temp
);
2107 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
2108 S_GET_NAME (symbolP
));
2110 subseg_set (current_seg
, current_subseg
);
2112 demand_empty_rest_of_line ();
2113 } /* s_lcomm_internal() */
2116 s_lcomm (needs_align
)
2119 s_lcomm_internal (needs_align
, 0);
2122 void s_lcomm_bytes (needs_align
)
2125 s_lcomm_internal (needs_align
, 1);
2130 int ignore ATTRIBUTE_UNUSED
;
2132 register char *name
;
2136 register symbolS
*symbolP
;
2138 /* we permit ANY defined expression: BSD4.2 demands constants */
2139 name
= input_line_pointer
;
2140 c
= get_symbol_end ();
2141 p
= input_line_pointer
;
2144 if (*input_line_pointer
!= ',')
2147 as_bad (_("Expected comma after name \"%s\""), name
);
2149 ignore_rest_of_line ();
2152 input_line_pointer
++;
2154 if (exp
.X_op
!= O_constant
2155 && exp
.X_op
!= O_register
)
2157 as_bad (_("bad expression"));
2158 ignore_rest_of_line ();
2162 symbolP
= symbol_find_or_make (name
);
2164 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2165 symbolP->sy_desc == 0) out of this test because coff doesn't have
2166 those fields, and I can't see when they'd ever be tripped. I
2167 don't think I understand why they were here so I may have
2168 introduced a bug. As recently as 1.37 didn't have this test
2169 anyway. xoxorich. */
2171 if (S_GET_SEGMENT (symbolP
) == undefined_section
2172 && S_GET_VALUE (symbolP
) == 0)
2174 /* The name might be an undefined .global symbol; be sure to
2175 keep the "external" bit. */
2176 S_SET_SEGMENT (symbolP
,
2177 (exp
.X_op
== O_constant
2180 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2184 as_bad (_("Symbol %s already defined"), name
);
2187 demand_empty_rest_of_line ();
2190 /* Read a line into an sb. */
2196 char quote1
, quote2
, inquote
;
2198 if (input_line_pointer
[-1] == '\n')
2199 bump_line_counters ();
2201 if (input_line_pointer
>= buffer_limit
)
2203 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2204 if (buffer_limit
== 0)
2208 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2209 code needs to be changed. */
2210 if (! flag_m68k_mri
)
2218 #ifdef LEX_IS_STRINGQUOTE
2223 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
2224 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2226 if (inquote
== *input_line_pointer
)
2228 else if (inquote
== '\0')
2230 if (*input_line_pointer
== quote1
)
2232 else if (*input_line_pointer
== quote2
)
2235 sb_add_char (line
, *input_line_pointer
++);
2237 while (input_line_pointer
< buffer_limit
2238 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2240 if (input_line_pointer
[-1] == '\n')
2241 bump_line_counters ();
2242 ++input_line_pointer
;
2247 /* Define a macro. This is an interface to macro.c, which is shared
2248 between gas and gasp. */
2252 int ignore ATTRIBUTE_UNUSED
;
2261 as_where (&file
, &line
);
2264 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
2265 sb_add_char (&s
, *input_line_pointer
++);
2268 if (line_label
!= NULL
)
2269 sb_add_string (&label
, S_GET_NAME (line_label
));
2271 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2273 as_bad_where (file
, line
, "%s", err
);
2276 if (line_label
!= NULL
)
2278 S_SET_SEGMENT (line_label
, undefined_section
);
2279 S_SET_VALUE (line_label
, 0);
2280 symbol_set_frag (line_label
, &zero_address_frag
);
2283 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2284 && hash_find (po_hash
, name
) != NULL
)
2287 && hash_find (po_hash
, name
+ 1) != NULL
))
2288 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2295 /* Handle the .mexit pseudo-op, which immediately exits a macro
2300 int ignore ATTRIBUTE_UNUSED
;
2302 cond_exit_macro (macro_nest
);
2303 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2306 /* Switch in and out of MRI mode. */
2310 int ignore ATTRIBUTE_UNUSED
;
2314 on
= get_absolute_expression ();
2315 old_flag
= flag_mri
;
2333 /* Operator precedence changes in m68k MRI mode, so we need to
2334 update the operator rankings. */
2335 expr_set_precedence ();
2337 #ifdef MRI_MODE_CHANGE
2339 MRI_MODE_CHANGE (on
);
2342 demand_empty_rest_of_line ();
2345 /* Handle changing the location counter. */
2348 do_org (segment
, exp
, fill
)
2353 if (segment
!= now_seg
&& segment
!= absolute_section
)
2354 as_bad (_("invalid segment \"%s\"; segment \"%s\" assumed"),
2355 segment_name (segment
), segment_name (now_seg
));
2357 if (now_seg
== absolute_section
)
2360 as_warn (_("ignoring fill value in absolute section"));
2361 if (exp
->X_op
!= O_constant
)
2363 as_bad (_("only constant offsets supported in absolute section"));
2364 exp
->X_add_number
= 0;
2366 abs_section_offset
= exp
->X_add_number
;
2372 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
->X_add_symbol
,
2373 exp
->X_add_number
* OCTETS_PER_BYTE
, (char *) NULL
);
2380 int ignore ATTRIBUTE_UNUSED
;
2382 register segT segment
;
2384 register long temp_fill
;
2386 #ifdef md_flush_pending_output
2387 md_flush_pending_output ();
2390 /* The m68k MRI assembler has a different meaning for .org. It
2391 means to create an absolute section at a given address. We can't
2392 support that--use a linker script instead. */
2395 as_bad (_("MRI style ORG pseudo-op not supported"));
2396 ignore_rest_of_line ();
2400 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2401 thing as a sub-segment-relative origin. Any absolute origin is
2402 given a warning, then assumed to be segment-relative. Any
2403 segmented origin expression ("foo+42") had better be in the right
2404 segment or the .org is ignored.
2406 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2407 we never know sub-segment sizes when we are reading code. BSD
2408 will crash trying to emit negative numbers of filler bytes in
2409 certain .orgs. We don't crash, but see as-write for that code.
2411 Don't make frag if need_pass_2==1. */
2412 segment
= get_known_segmented_expression (&exp
);
2413 if (*input_line_pointer
== ',')
2415 input_line_pointer
++;
2416 temp_fill
= get_absolute_expression ();
2422 do_org (segment
, &exp
, temp_fill
);
2424 demand_empty_rest_of_line ();
2427 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2428 called by the obj-format routine which handles section changing
2429 when in MRI mode. It will create a new section, and return it. It
2430 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2431 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2432 flags will be set in the section. */
2436 char *type ATTRIBUTE_UNUSED
;
2446 name
= input_line_pointer
;
2447 if (! isdigit ((unsigned char) *name
))
2448 c
= get_symbol_end ();
2453 ++input_line_pointer
;
2455 while (isdigit ((unsigned char) *input_line_pointer
));
2456 c
= *input_line_pointer
;
2457 *input_line_pointer
= '\0';
2460 name
= xstrdup (name
);
2462 *input_line_pointer
= c
;
2464 seg
= subseg_new (name
, 0);
2466 if (*input_line_pointer
== ',')
2470 ++input_line_pointer
;
2471 align
= get_absolute_expression ();
2472 record_alignment (seg
, align
);
2476 if (*input_line_pointer
== ',')
2478 c
= *++input_line_pointer
;
2479 c
= toupper ((unsigned char) c
);
2480 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2483 as_bad (_("unrecognized section type"));
2484 ++input_line_pointer
;
2486 #ifdef BFD_ASSEMBLER
2490 flags
= SEC_NO_FLAGS
;
2492 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2493 else if (*type
== 'D' || *type
== 'M')
2494 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2495 else if (*type
== 'R')
2496 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2497 if (flags
!= SEC_NO_FLAGS
)
2499 if (! bfd_set_section_flags (stdoutput
, seg
, flags
))
2500 as_warn (_("error setting flags for \"%s\": %s"),
2501 bfd_section_name (stdoutput
, seg
),
2502 bfd_errmsg (bfd_get_error ()));
2508 /* Ignore the HP type. */
2509 if (*input_line_pointer
== ',')
2510 input_line_pointer
+= 2;
2512 demand_empty_rest_of_line ();
2514 #else /* ! TC_M68K */
2523 name
= input_line_pointer
;
2524 c
= get_symbol_end ();
2526 name
= xstrdup (name
);
2528 *input_line_pointer
= c
;
2530 seg
= subseg_new (name
, 0);
2532 if (*input_line_pointer
!= ',')
2538 ++input_line_pointer
;
2540 sectype
= input_line_pointer
;
2541 c
= get_symbol_end ();
2542 if (*sectype
== '\0')
2544 else if (strcasecmp (sectype
, "text") == 0)
2546 else if (strcasecmp (sectype
, "data") == 0)
2548 else if (strcasecmp (sectype
, "romdata") == 0)
2551 as_warn (_("unrecognized section type `%s'"), sectype
);
2552 *input_line_pointer
= c
;
2555 if (*input_line_pointer
== ',')
2559 ++input_line_pointer
;
2561 seccmd
= input_line_pointer
;
2562 c
= get_symbol_end ();
2563 if (strcasecmp (seccmd
, "absolute") == 0)
2565 as_bad (_("absolute sections are not supported"));
2566 *input_line_pointer
= c
;
2567 ignore_rest_of_line ();
2570 else if (strcasecmp (seccmd
, "align") == 0)
2574 *input_line_pointer
= c
;
2575 align
= get_absolute_expression ();
2576 record_alignment (seg
, align
);
2580 as_warn (_("unrecognized section command `%s'"), seccmd
);
2581 *input_line_pointer
= c
;
2585 demand_empty_rest_of_line ();
2587 #else /* ! TC_I960 */
2588 /* The MRI assembler seems to use different forms of .sect for
2589 different targets. */
2590 as_bad ("MRI mode not supported for this target");
2591 ignore_rest_of_line ();
2592 #endif /* ! TC_I960 */
2593 #endif /* ! TC_M68K */
2596 /* Handle the .print pseudo-op. */
2600 int ignore ATTRIBUTE_UNUSED
;
2605 s
= demand_copy_C_string (&len
);
2607 demand_empty_rest_of_line ();
2610 /* Handle the .purgem pseudo-op. */
2614 int ignore ATTRIBUTE_UNUSED
;
2616 if (is_it_end_of_statement ())
2618 demand_empty_rest_of_line ();
2628 name
= input_line_pointer
;
2629 c
= get_symbol_end ();
2630 delete_macro (name
);
2631 *input_line_pointer
= c
;
2634 while (*input_line_pointer
++ == ',');
2636 --input_line_pointer
;
2637 demand_empty_rest_of_line ();
2640 /* Handle the .rept pseudo-op. */
2644 int ignore ATTRIBUTE_UNUSED
;
2648 count
= get_absolute_expression ();
2650 do_repeat(count
, "REPT", "ENDR");
2653 /* This function provides a generic repeat block implementation. It allows
2654 different directives to be used as the start/end keys. */
2657 do_repeat (count
, start
, end
)
2666 if (! buffer_and_nest (start
, end
, &one
, get_line_sb
))
2668 as_bad (_("%s without %s"), start
, end
);
2674 sb_add_sb (&many
, &one
);
2678 input_scrub_include_sb (&many
, input_line_pointer
);
2680 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2683 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2684 input buffers to skip. Assumes that conditionals preceding the loop end
2685 are properly nested.
2687 This function makes it easier to implement a premature "break" out of the
2688 loop. The EXTRA arg accounts for other buffers we might have inserted,
2689 such as line substitutions. */
2695 cond_exit_macro (macro_nest
);
2696 while (extra
-- >= 0)
2697 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2700 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2701 this is .equiv, and it is an error if the symbol is already
2708 register char *name
;
2709 register char delim
;
2710 register char *end_name
;
2711 register symbolS
*symbolP
;
2714 * Especial apologies for the random logic:
2715 * this just grew, and could be parsed much more simply!
2718 name
= input_line_pointer
;
2719 delim
= get_symbol_end ();
2720 end_name
= input_line_pointer
;
2724 if (*input_line_pointer
!= ',')
2727 as_bad (_("Expected comma after name \"%s\""), name
);
2729 ignore_rest_of_line ();
2733 input_line_pointer
++;
2736 if (name
[0] == '.' && name
[1] == '\0')
2738 /* Turn '. = mumble' into a .org mumble */
2739 register segT segment
;
2742 segment
= get_known_segmented_expression (&exp
);
2745 do_org (segment
, &exp
, 0);
2751 if ((symbolP
= symbol_find (name
)) == NULL
2752 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2755 /* When doing symbol listings, play games with dummy fragments living
2756 outside the normal fragment chain to record the file and line info
2758 if (listing
& LISTING_SYMBOLS
)
2760 extern struct list_info_struct
*listing_tail
;
2761 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof(fragS
));
2762 memset (dummy_frag
, 0, sizeof(fragS
));
2763 dummy_frag
->fr_type
= rs_fill
;
2764 dummy_frag
->line
= listing_tail
;
2765 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2766 dummy_frag
->fr_symbol
= symbolP
;
2770 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2773 /* "set" symbols are local unless otherwise specified. */
2774 SF_SET_LOCAL (symbolP
);
2775 #endif /* OBJ_COFF */
2777 } /* make a new symbol */
2779 symbol_table_insert (symbolP
);
2784 && S_IS_DEFINED (symbolP
)
2785 && S_GET_SEGMENT (symbolP
) != reg_section
)
2786 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
2788 pseudo_set (symbolP
);
2789 demand_empty_rest_of_line ();
2803 #ifdef md_flush_pending_output
2804 md_flush_pending_output ();
2808 stop
= mri_comment_field (&stopc
);
2810 /* In m68k MRI mode, we need to align to a word boundary, unless
2812 if (flag_m68k_mri
&& mult
> 1)
2814 if (now_seg
== absolute_section
)
2816 abs_section_offset
+= abs_section_offset
& 1;
2817 if (line_label
!= NULL
)
2818 S_SET_VALUE (line_label
, abs_section_offset
);
2820 else if (mri_common_symbol
!= NULL
)
2824 val
= S_GET_VALUE (mri_common_symbol
);
2827 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2828 if (line_label
!= NULL
)
2830 expressionS
*symexp
;
2832 symexp
= symbol_get_value_expression (line_label
);
2833 know (symexp
->X_op
== O_symbol
);
2834 know (symexp
->X_add_symbol
== mri_common_symbol
);
2835 symexp
->X_add_number
+= 1;
2841 do_align (1, (char *) NULL
, 0, 0);
2842 if (line_label
!= NULL
)
2844 symbol_set_frag (line_label
, frag_now
);
2845 S_SET_VALUE (line_label
, frag_now_fix ());
2855 if (*input_line_pointer
== ',')
2857 ++input_line_pointer
;
2862 val
.X_op
= O_constant
;
2863 val
.X_add_number
= 0;
2866 if (val
.X_op
!= O_constant
2867 || val
.X_add_number
< - 0x80
2868 || val
.X_add_number
> 0xff
2869 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2871 if (exp
.X_op
!= O_constant
)
2872 as_bad (_("Unsupported variable size or fill value"));
2879 bytes
= mult
* exp
.X_add_number
;
2880 for (i
= 0; i
< exp
.X_add_number
; i
++)
2881 emit_expr (&val
, mult
);
2886 if (exp
.X_op
== O_constant
)
2890 repeat
= exp
.X_add_number
;
2897 as_warn (_(".space repeat count is zero, ignored"));
2898 else if (repeat
< 0)
2899 as_warn (_(".space repeat count is negative, ignored"));
2903 /* If we are in the absolute section, just bump the offset. */
2904 if (now_seg
== absolute_section
)
2906 abs_section_offset
+= repeat
;
2910 /* If we are secretly in an MRI common section, then
2911 creating space just increases the size of the common
2913 if (mri_common_symbol
!= NULL
)
2915 S_SET_VALUE (mri_common_symbol
,
2916 S_GET_VALUE (mri_common_symbol
) + repeat
);
2921 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2922 (offsetT
) repeat
, (char *) 0);
2926 if (now_seg
== absolute_section
)
2928 as_bad (_("space allocation too complex in absolute section"));
2929 subseg_set (text_section
, 0);
2931 if (mri_common_symbol
!= NULL
)
2933 as_bad (_("space allocation too complex in common section"));
2934 mri_common_symbol
= NULL
;
2937 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2938 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2942 *p
= val
.X_add_number
;
2947 /* In MRI mode, after an odd number of bytes, we must align to an
2948 even word boundary, unless the next instruction is a dc.b, ds.b
2950 if (flag_mri
&& (bytes
& 1) != 0)
2951 mri_pending_align
= 1;
2953 demand_empty_rest_of_line ();
2956 mri_comment_end (stop
, stopc
);
2959 /* This is like s_space, but the value is a floating point number with
2960 the given precision. This is for the MRI dcb.s pseudo-op and
2964 s_float_space (float_type
)
2969 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2974 stop
= mri_comment_field (&stopc
);
2976 count
= get_absolute_expression ();
2979 if (*input_line_pointer
!= ',')
2981 as_bad (_("missing value"));
2982 ignore_rest_of_line ();
2984 mri_comment_end (stop
, stopc
);
2988 ++input_line_pointer
;
2992 /* Skip any 0{letter} that may be present. Don't even check if the
2993 * letter is legal. */
2994 if (input_line_pointer
[0] == '0'
2995 && isalpha ((unsigned char) input_line_pointer
[1]))
2996 input_line_pointer
+= 2;
2998 /* Accept :xxxx, where the x's are hex digits, for a floating point
2999 with the exact digits specified. */
3000 if (input_line_pointer
[0] == ':')
3002 flen
= hex_float (float_type
, temp
);
3005 ignore_rest_of_line ();
3007 mri_comment_end (stop
, stopc
);
3015 err
= md_atof (float_type
, temp
, &flen
);
3016 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3020 as_bad (_("Bad floating literal: %s"), err
);
3021 ignore_rest_of_line ();
3023 mri_comment_end (stop
, stopc
);
3028 while (--count
>= 0)
3032 p
= frag_more (flen
);
3033 memcpy (p
, temp
, (unsigned int) flen
);
3036 demand_empty_rest_of_line ();
3039 mri_comment_end (stop
, stopc
);
3042 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3046 int ignore ATTRIBUTE_UNUSED
;
3052 stop
= mri_comment_field (&stopc
);
3053 abs_section_offset
= get_absolute_expression ();
3054 subseg_set (absolute_section
, 0);
3055 demand_empty_rest_of_line ();
3057 mri_comment_end (stop
, stopc
);
3062 int ignore ATTRIBUTE_UNUSED
;
3066 temp
= get_absolute_expression ();
3067 subseg_set (text_section
, (subsegT
) temp
);
3068 demand_empty_rest_of_line ();
3070 const_flag
&= ~IN_DEFAULT_SECTION
;
3076 demand_empty_rest_of_line ()
3079 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3081 input_line_pointer
++;
3085 ignore_rest_of_line ();
3087 /* Return having already swallowed end-of-line. */
3088 } /* Return pointing just after end-of-line. */
3091 ignore_rest_of_line () /* For suspect lines: gives warning. */
3093 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3095 if (isprint ((unsigned char) *input_line_pointer
))
3096 as_bad (_("Rest of line ignored. First ignored character is `%c'."),
3097 *input_line_pointer
);
3099 as_bad (_("Rest of line ignored. First ignored character valued 0x%x."),
3100 *input_line_pointer
);
3101 while (input_line_pointer
< buffer_limit
3102 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3104 input_line_pointer
++;
3107 input_line_pointer
++; /* Return pointing just after end-of-line. */
3108 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3112 discard_rest_of_line ()
3114 while (input_line_pointer
< buffer_limit
3115 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3117 input_line_pointer
++;
3119 input_line_pointer
++; /* Return pointing just after end-of-line. */
3120 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3126 * In: Pointer to a symbol.
3127 * Input_line_pointer->expression.
3129 * Out: Input_line_pointer->just after any whitespace after expression.
3130 * Tried to set symbol to value of expression.
3131 * Will change symbols type, value, and frag;
3134 pseudo_set (symbolP
)
3138 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3140 #endif /* OBJ_AOUT or OBJ_BOUT */
3142 know (symbolP
); /* NULL pointer is logic error. */
3143 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3144 ext
= S_IS_EXTERNAL (symbolP
);
3145 #endif /* OBJ_AOUT or OBJ_BOUT */
3147 (void) expression (&exp
);
3149 if (exp
.X_op
== O_illegal
)
3150 as_bad (_("illegal expression; zero assumed"));
3151 else if (exp
.X_op
== O_absent
)
3152 as_bad (_("missing expression; zero assumed"));
3153 else if (exp
.X_op
== O_big
)
3155 if (exp
.X_add_number
> 0)
3156 as_bad (_("bignum invalid; zero assumed"));
3158 as_bad (_("floating point number invalid; zero assumed"));
3160 else if (exp
.X_op
== O_subtract
3161 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3162 == S_GET_SEGMENT (exp
.X_op_symbol
))
3163 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3164 && (symbol_get_frag (exp
.X_add_symbol
)
3165 == symbol_get_frag (exp
.X_op_symbol
)))
3167 exp
.X_op
= O_constant
;
3168 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3169 - S_GET_VALUE (exp
.X_op_symbol
));
3177 exp
.X_add_number
= 0;
3180 S_SET_SEGMENT (symbolP
, absolute_section
);
3181 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3183 S_SET_EXTERNAL (symbolP
);
3185 S_CLEAR_EXTERNAL (symbolP
);
3186 #endif /* OBJ_AOUT or OBJ_BOUT */
3187 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3188 if (exp
.X_op
!= O_constant
)
3189 symbol_set_frag (symbolP
, &zero_address_frag
);
3193 S_SET_SEGMENT (symbolP
, reg_section
);
3194 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3195 symbol_set_frag (symbolP
, &zero_address_frag
);
3199 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3200 || exp
.X_add_number
!= 0)
3201 symbol_set_value_expression (symbolP
, &exp
);
3202 else if (symbol_section_p (symbolP
))
3203 as_bad ("invalid attempt to set value of section symbol");
3206 symbolS
*s
= exp
.X_add_symbol
;
3208 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3209 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3211 S_SET_EXTERNAL (symbolP
);
3213 S_CLEAR_EXTERNAL (symbolP
);
3214 #endif /* OBJ_AOUT or OBJ_BOUT */
3215 S_SET_VALUE (symbolP
,
3216 exp
.X_add_number
+ S_GET_VALUE (s
));
3217 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3218 copy_symbol_attributes (symbolP
, s
);
3223 /* The value is some complex expression.
3224 FIXME: Should we set the segment to anything? */
3225 symbol_set_value_expression (symbolP
, &exp
);
3233 * CONStruct more frag of .bytes, or .words etc.
3234 * Should need_pass_2 be 1 then emit no frag(s).
3235 * This understands EXPRESSIONS.
3239 * This has a split personality. We use expression() to read the
3240 * value. We can detect if the value won't fit in a byte or word.
3241 * But we can't detect if expression() discarded significant digits
3242 * in the case of a long. Not worth the crocks required to fix it.
3245 /* Select a parser for cons expressions. */
3247 /* Some targets need to parse the expression in various fancy ways.
3248 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3249 (for example, the HPPA does this). Otherwise, you can define
3250 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3251 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3252 are defined, which is the normal case, then only simple expressions
3257 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3260 #ifndef TC_PARSE_CONS_EXPRESSION
3261 #ifdef BITFIELD_CONS_EXPRESSIONS
3262 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3264 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3266 #ifdef REPEAT_CONS_EXPRESSIONS
3267 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3269 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3272 /* If we haven't gotten one yet, just call expression. */
3273 #ifndef TC_PARSE_CONS_EXPRESSION
3274 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3278 /* worker to do .byte etc statements */
3279 /* clobbers input_line_pointer, checks */
3282 cons_worker (nbytes
, rva
)
3283 register int nbytes
; /* 1=.byte, 2=.word, 4=.long */
3291 #ifdef md_flush_pending_output
3292 md_flush_pending_output ();
3296 stop
= mri_comment_field (&stopc
);
3298 if (is_it_end_of_statement ())
3300 demand_empty_rest_of_line ();
3302 mri_comment_end (stop
, stopc
);
3306 #ifdef md_cons_align
3307 md_cons_align (nbytes
);
3315 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3318 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3322 if (exp
.X_op
== O_symbol
)
3323 exp
.X_op
= O_symbol_rva
;
3325 as_fatal (_("rva without symbol"));
3327 emit_expr (&exp
, (unsigned int) nbytes
);
3330 while (*input_line_pointer
++ == ',');
3332 /* In MRI mode, after an odd number of bytes, we must align to an
3333 even word boundary, unless the next instruction is a dc.b, ds.b
3335 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3336 mri_pending_align
= 1;
3338 input_line_pointer
--; /* Put terminator back into stream. */
3340 demand_empty_rest_of_line ();
3343 mri_comment_end (stop
, stopc
);
3351 cons_worker (size
, 0);
3358 cons_worker (size
, 1);
3361 /* Put the contents of expression EXP into the object file using
3362 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3365 emit_expr (exp
, nbytes
)
3367 unsigned int nbytes
;
3371 valueT extra_digit
= 0;
3373 /* Don't do anything if we are going to make another pass. */
3379 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3380 appear as a four byte positive constant in the .line section,
3381 followed by a 2 byte 0xffff. Look for that case here. */
3383 static int dwarf_line
= -1;
3385 if (strcmp (segment_name (now_seg
), ".line") != 0)
3387 else if (dwarf_line
>= 0
3389 && exp
->X_op
== O_constant
3390 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3391 listing_source_line ((unsigned int) dwarf_line
);
3392 else if (nbytes
== 4
3393 && exp
->X_op
== O_constant
3394 && exp
->X_add_number
>= 0)
3395 dwarf_line
= exp
->X_add_number
;
3400 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3401 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3402 AT_sibling (0x12) followed by a four byte address of the sibling
3403 followed by a 2 byte AT_name (0x38) followed by the name of the
3404 file. We look for that case here. */
3406 static int dwarf_file
= 0;
3408 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3410 else if (dwarf_file
== 0
3412 && exp
->X_op
== O_constant
3413 && exp
->X_add_number
== 0x11)
3415 else if (dwarf_file
== 1
3417 && exp
->X_op
== O_constant
3418 && exp
->X_add_number
== 0x12)
3420 else if (dwarf_file
== 2
3423 else if (dwarf_file
== 3
3425 && exp
->X_op
== O_constant
3426 && exp
->X_add_number
== 0x38)
3431 /* The variable dwarf_file_string tells stringer that the string
3432 may be the name of the source file. */
3433 if (dwarf_file
== 4)
3434 dwarf_file_string
= 1;
3436 dwarf_file_string
= 0;
3441 if (check_eh_frame (exp
, &nbytes
))
3446 /* Allow `.word 0' in the absolute section. */
3447 if (now_seg
== absolute_section
)
3449 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3450 as_bad (_("attempt to store value in absolute section"));
3451 abs_section_offset
+= nbytes
;
3455 /* Handle a negative bignum. */
3457 && exp
->X_add_number
== 0
3458 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3459 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3462 unsigned long carry
;
3464 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3466 /* Negate the bignum: one's complement each digit and add 1. */
3468 for (i
= 0; i
< exp
->X_add_number
; i
++)
3472 next
= (((~ (generic_bignum
[i
] & LITTLENUM_MASK
))
3475 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3476 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3479 /* We can ignore any carry out, because it will be handled by
3480 extra_digit if it is needed. */
3482 extra_digit
= (valueT
) -1;
3486 if (op
== O_absent
|| op
== O_illegal
)
3488 as_warn (_("zero assumed for missing expression"));
3489 exp
->X_add_number
= 0;
3492 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3494 as_bad (_("floating point number invalid; zero assumed"));
3495 exp
->X_add_number
= 0;
3498 else if (op
== O_register
)
3500 as_warn (_("register value used as expression"));
3504 p
= frag_more ((int) nbytes
);
3506 #ifndef WORKING_DOT_WORD
3507 /* If we have the difference of two symbols in a word, save it on
3508 the broken_words list. See the code in write.c. */
3509 if (op
== O_subtract
&& nbytes
== 2)
3511 struct broken_word
*x
;
3513 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3514 x
->next_broken_word
= broken_words
;
3517 x
->subseg
= now_subseg
;
3519 x
->word_goes_here
= p
;
3521 x
->add
= exp
->X_add_symbol
;
3522 x
->sub
= exp
->X_op_symbol
;
3523 x
->addnum
= exp
->X_add_number
;
3530 /* If we have an integer, but the number of bytes is too large to
3531 pass to md_number_to_chars, handle it as a bignum. */
3532 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3537 if (! exp
->X_unsigned
&& exp
->X_add_number
< 0)
3538 extra_digit
= (valueT
) -1;
3539 val
= (valueT
) exp
->X_add_number
;
3543 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3544 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3548 op
= exp
->X_op
= O_big
;
3549 exp
->X_add_number
= gencnt
;
3552 if (op
== O_constant
)
3554 register valueT get
;
3555 register valueT use
;
3556 register valueT mask
;
3558 register valueT unmask
;
3560 /* JF << of >= number of bits in the object is undefined. In
3561 particular SPARC (Sun 4) has problems */
3562 if (nbytes
>= sizeof (valueT
))
3565 if (nbytes
> sizeof (valueT
))
3568 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3572 /* Don't store these bits. */
3573 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3574 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3577 unmask
= ~mask
; /* Do store these bits. */
3580 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3581 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3584 get
= exp
->X_add_number
;
3586 if ((get
& mask
) != 0
3587 && ((get
& mask
) != mask
3588 || (get
& hibit
) == 0))
3589 { /* Leading bits contain both 0s & 1s. */
3590 as_warn (_("Value 0x%lx truncated to 0x%lx."),
3591 (unsigned long) get
, (unsigned long) use
);
3593 /* put bytes in right order. */
3594 md_number_to_chars (p
, use
, (int) nbytes
);
3596 else if (op
== O_big
)
3599 LITTLENUM_TYPE
*nums
;
3601 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3603 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3606 as_warn (_("Bignum truncated to %d bytes"), nbytes
);
3610 if (target_big_endian
)
3612 while (nbytes
> size
)
3614 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3615 nbytes
-= CHARS_PER_LITTLENUM
;
3616 p
+= CHARS_PER_LITTLENUM
;
3619 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3623 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3624 size
-= CHARS_PER_LITTLENUM
;
3625 p
+= CHARS_PER_LITTLENUM
;
3630 nums
= generic_bignum
;
3633 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3635 size
-= CHARS_PER_LITTLENUM
;
3636 p
+= CHARS_PER_LITTLENUM
;
3637 nbytes
-= CHARS_PER_LITTLENUM
;
3642 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3643 nbytes
-= CHARS_PER_LITTLENUM
;
3644 p
+= CHARS_PER_LITTLENUM
;
3650 memset (p
, 0, nbytes
);
3652 /* Now we need to generate a fixS to record the symbol value.
3653 This is easy for BFD. For other targets it can be more
3654 complex. For very complex cases (currently, the HPPA and
3655 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3656 want. For simpler cases, you can define TC_CONS_RELOC to be
3657 the name of the reloc code that should be stored in the fixS.
3658 If neither is defined, the code uses NO_RELOC if it is
3659 defined, and otherwise uses 0. */
3661 #ifdef BFD_ASSEMBLER
3662 #ifdef TC_CONS_FIX_NEW
3663 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3666 bfd_reloc_code_real_type r
;
3683 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3687 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3692 #ifdef TC_CONS_FIX_NEW
3693 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3695 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3696 it is defined, otherwise use NO_RELOC if it is defined,
3698 #ifndef TC_CONS_RELOC
3700 #define TC_CONS_RELOC NO_RELOC
3702 #define TC_CONS_RELOC 0
3705 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3707 #endif /* TC_CONS_FIX_NEW */
3708 #endif /* BFD_ASSEMBLER */
3712 #ifdef BITFIELD_CONS_EXPRESSIONS
3714 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3715 w:x,y:z, where w and y are bitwidths and x and y are values. They
3716 then pack them all together. We do a little better in that we allow
3717 them in words, longs, etc. and we'll pack them in target byte order
3720 The rules are: pack least significat bit first, if a field doesn't
3721 entirely fit, put it in the next unit. Overflowing the bitfield is
3722 explicitly *not* even a warning. The bitwidth should be considered
3725 To use this function the tc-XXX.h file should define
3726 BITFIELD_CONS_EXPRESSIONS. */
3729 parse_bitfield_cons (exp
, nbytes
)
3731 unsigned int nbytes
;
3733 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3734 char *hold
= input_line_pointer
;
3736 (void) expression (exp
);
3738 if (*input_line_pointer
== ':')
3744 unsigned long width
;
3746 if (*input_line_pointer
!= ':')
3748 input_line_pointer
= hold
;
3750 } /* next piece is not a bitfield */
3752 /* In the general case, we can't allow
3753 full expressions with symbol
3754 differences and such. The relocation
3755 entries for symbols not defined in this
3756 assembly would require arbitrary field
3757 widths, positions, and masks which most
3758 of our current object formats don't
3761 In the specific case where a symbol
3762 *is* defined in this assembly, we
3763 *could* build fixups and track it, but
3764 this could lead to confusion for the
3765 backends. I'm lazy. I'll take any
3766 SEG_ABSOLUTE. I think that means that
3767 you can use a previous .set or
3768 .equ type symbol. xoxorich. */
3770 if (exp
->X_op
== O_absent
)
3772 as_warn (_("using a bit field width of zero"));
3773 exp
->X_add_number
= 0;
3774 exp
->X_op
= O_constant
;
3775 } /* implied zero width bitfield */
3777 if (exp
->X_op
!= O_constant
)
3779 *input_line_pointer
= '\0';
3780 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3781 *input_line_pointer
= ':';
3782 demand_empty_rest_of_line ();
3786 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3788 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3789 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3790 width
= BITS_PER_CHAR
* nbytes
;
3793 if (width
> bits_available
)
3795 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3796 input_line_pointer
= hold
;
3797 exp
->X_add_number
= value
;
3801 hold
= ++input_line_pointer
; /* skip ':' */
3803 (void) expression (exp
);
3804 if (exp
->X_op
!= O_constant
)
3806 char cache
= *input_line_pointer
;
3808 *input_line_pointer
= '\0';
3809 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3810 *input_line_pointer
= cache
;
3811 demand_empty_rest_of_line ();
3815 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3816 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3818 if ((bits_available
-= width
) == 0
3819 || is_it_end_of_statement ()
3820 || *input_line_pointer
!= ',')
3823 } /* all the bitfields we're gonna get */
3825 hold
= ++input_line_pointer
;
3826 (void) expression (exp
);
3827 } /* forever loop */
3829 exp
->X_add_number
= value
;
3830 exp
->X_op
= O_constant
;
3831 exp
->X_unsigned
= 1;
3832 } /* if looks like a bitfield */
3833 } /* parse_bitfield_cons() */
3835 #endif /* BITFIELD_CONS_EXPRESSIONS */
3837 /* Handle an MRI style string expression. */
3841 parse_mri_cons (exp
, nbytes
)
3843 unsigned int nbytes
;
3845 if (*input_line_pointer
!= '\''
3846 && (input_line_pointer
[1] != '\''
3847 || (*input_line_pointer
!= 'A'
3848 && *input_line_pointer
!= 'E')))
3849 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3853 unsigned int result
= 0;
3855 /* An MRI style string. Cut into as many bytes as will fit into
3856 a nbyte chunk, left justify if necessary, and separate with
3857 commas so we can try again later. */
3858 if (*input_line_pointer
== 'A')
3859 ++input_line_pointer
;
3860 else if (*input_line_pointer
== 'E')
3862 as_bad (_("EBCDIC constants are not supported"));
3863 ++input_line_pointer
;
3866 input_line_pointer
++;
3867 for (scan
= 0; scan
< nbytes
; scan
++)
3869 if (*input_line_pointer
== '\'')
3871 if (input_line_pointer
[1] == '\'')
3873 input_line_pointer
++;
3878 result
= (result
<< 8) | (*input_line_pointer
++);
3882 while (scan
< nbytes
)
3887 /* Create correct expression */
3888 exp
->X_op
= O_constant
;
3889 exp
->X_add_number
= result
;
3890 /* Fake it so that we can read the next char too */
3891 if (input_line_pointer
[0] != '\'' ||
3892 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3894 input_line_pointer
-= 2;
3895 input_line_pointer
[0] = ',';
3896 input_line_pointer
[1] = '\'';
3899 input_line_pointer
++;
3902 #endif /* TC_M68K */
3904 #ifdef REPEAT_CONS_EXPRESSIONS
3906 /* Parse a repeat expression for cons. This is used by the MIPS
3907 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3908 object file COUNT times.
3910 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3913 parse_repeat_cons (exp
, nbytes
)
3915 unsigned int nbytes
;
3922 if (*input_line_pointer
!= ':')
3924 /* No repeat count. */
3928 ++input_line_pointer
;
3929 expression (&count
);
3930 if (count
.X_op
!= O_constant
3931 || count
.X_add_number
<= 0)
3933 as_warn (_("Unresolvable or nonpositive repeat count; using 1"));
3937 /* The cons function is going to output this expression once. So we
3938 output it count - 1 times. */
3939 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3940 emit_expr (exp
, nbytes
);
3943 #endif /* REPEAT_CONS_EXPRESSIONS */
3945 /* Parse a floating point number represented as a hex constant. This
3946 permits users to specify the exact bits they want in the floating
3950 hex_float (float_type
, bytes
)
3984 as_bad (_("Unknown floating type type '%c'"), float_type
);
3988 /* It would be nice if we could go through expression to parse the
3989 hex constant, but if we get a bignum it's a pain to sort it into
3990 the buffer correctly. */
3992 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
3996 /* The MRI assembler accepts arbitrary underscores strewn about
3997 through the hex constant, so we ignore them as well. */
3998 if (*input_line_pointer
== '_')
4000 ++input_line_pointer
;
4006 as_warn (_("Floating point constant too large"));
4009 d
= hex_value (*input_line_pointer
) << 4;
4010 ++input_line_pointer
;
4011 while (*input_line_pointer
== '_')
4012 ++input_line_pointer
;
4013 if (hex_p (*input_line_pointer
))
4015 d
+= hex_value (*input_line_pointer
);
4016 ++input_line_pointer
;
4018 if (target_big_endian
)
4021 bytes
[length
- i
- 1] = d
;
4027 if (target_big_endian
)
4028 memset (bytes
+ i
, 0, length
- i
);
4030 memset (bytes
, 0, length
- i
);
4039 * CONStruct some more frag chars of .floats .ffloats etc.
4040 * Makes 0 or more new frags.
4041 * If need_pass_2 == 1, no frags are emitted.
4042 * This understands only floating literals, not expressions. Sorry.
4044 * A floating constant is defined by atof_generic(), except it is preceded
4045 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4046 * reading, I decided to be incompatible. This always tries to give you
4047 * rounded bits to the precision of the pseudo-op. Former AS did premature
4048 * truncatation, restored noisy bits instead of trailing 0s AND gave you
4049 * a choice of 2 flavours of noise according to which of 2 floating-point
4050 * scanners you directed AS to use.
4052 * In: input_line_pointer->whitespace before, or '0' of flonum.
4057 float_cons (float_type
)
4058 /* Clobbers input_line-pointer, checks end-of-line. */
4059 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4062 int length
; /* Number of chars in an object. */
4063 register char *err
; /* Error from scanning floating literal. */
4064 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4066 if (is_it_end_of_statement ())
4068 demand_empty_rest_of_line ();
4072 #ifdef md_flush_pending_output
4073 md_flush_pending_output ();
4078 /* input_line_pointer->1st char of a flonum (we hope!). */
4081 /* Skip any 0{letter} that may be present. Don't even check if the
4082 * letter is legal. Someone may invent a "z" format and this routine
4083 * has no use for such information. Lusers beware: you get
4084 * diagnostics if your input is ill-conditioned.
4086 if (input_line_pointer
[0] == '0'
4087 && isalpha ((unsigned char) input_line_pointer
[1]))
4088 input_line_pointer
+= 2;
4090 /* Accept :xxxx, where the x's are hex digits, for a floating
4091 point with the exact digits specified. */
4092 if (input_line_pointer
[0] == ':')
4094 ++input_line_pointer
;
4095 length
= hex_float (float_type
, temp
);
4098 ignore_rest_of_line ();
4104 err
= md_atof (float_type
, temp
, &length
);
4105 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4109 as_bad (_("Bad floating literal: %s"), err
);
4110 ignore_rest_of_line ();
4121 #ifdef REPEAT_CONS_EXPRESSIONS
4122 if (*input_line_pointer
== ':')
4124 expressionS count_exp
;
4126 ++input_line_pointer
;
4127 expression (&count_exp
);
4128 if (count_exp
.X_op
!= O_constant
4129 || count_exp
.X_add_number
<= 0)
4131 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4134 count
= count_exp
.X_add_number
;
4138 while (--count
>= 0)
4140 p
= frag_more (length
);
4141 memcpy (p
, temp
, (unsigned int) length
);
4146 while (*input_line_pointer
++ == ',');
4148 --input_line_pointer
; /* Put terminator back into stream. */
4149 demand_empty_rest_of_line ();
4150 } /* float_cons() */
4152 /* Return the size of a LEB128 value */
4155 sizeof_sleb128 (value
)
4158 register int size
= 0;
4159 register unsigned byte
;
4163 byte
= (value
& 0x7f);
4164 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4165 Fortunately, we can structure things so that the extra work reduces
4166 to a noop on systems that do things "properly". */
4167 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4170 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4171 || ((value
== -1) && ((byte
& 0x40) != 0))));
4177 sizeof_uleb128 (value
)
4180 register int size
= 0;
4181 register unsigned byte
;
4185 byte
= (value
& 0x7f);
4195 sizeof_leb128 (value
, sign
)
4200 return sizeof_sleb128 ((offsetT
) value
);
4202 return sizeof_uleb128 (value
);
4205 /* Output a LEB128 value. */
4208 output_sleb128 (p
, value
)
4212 register char *orig
= p
;
4217 unsigned byte
= (value
& 0x7f);
4219 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4220 Fortunately, we can structure things so that the extra work reduces
4221 to a noop on systems that do things "properly". */
4222 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4224 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4225 || ((value
== -1) && ((byte
& 0x40) != 0))));
4237 output_uleb128 (p
, value
)
4245 unsigned byte
= (value
& 0x7f);
4248 /* More bytes to follow. */
4259 output_leb128 (p
, value
, sign
)
4265 return output_sleb128 (p
, (offsetT
) value
);
4267 return output_uleb128 (p
, value
);
4270 /* Do the same for bignums. We combine sizeof with output here in that
4271 we don't output for NULL values of P. It isn't really as critical as
4272 for "normal" values that this be streamlined. */
4275 output_big_sleb128 (p
, bignum
, size
)
4277 LITTLENUM_TYPE
*bignum
;
4285 /* Strip leading sign extensions off the bignum. */
4286 while (size
> 0 && bignum
[size
-1] == (LITTLENUM_TYPE
)-1)
4291 if (loaded
< 7 && size
> 0)
4293 val
|= (*bignum
<< loaded
);
4294 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4305 if ((val
== 0 && (byte
& 0x40) == 0)
4306 || (~(val
| ~(((valueT
)1 << loaded
) - 1)) == 0
4307 && (byte
& 0x40) != 0))
4315 while (byte
& 0x80);
4321 output_big_uleb128 (p
, bignum
, size
)
4323 LITTLENUM_TYPE
*bignum
;
4331 /* Strip leading zeros off the bignum. */
4332 /* XXX: Is this needed? */
4333 while (size
> 0 && bignum
[size
-1] == 0)
4338 if (loaded
< 7 && size
> 0)
4340 val
|= (*bignum
<< loaded
);
4341 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4350 if (size
> 0 || val
)
4357 while (byte
& 0x80);
4363 output_big_leb128 (p
, bignum
, size
, sign
)
4365 LITTLENUM_TYPE
*bignum
;
4369 return output_big_sleb128 (p
, bignum
, size
);
4371 return output_big_uleb128 (p
, bignum
, size
);
4374 /* Generate the appropriate fragments for a given expression to emit a
4378 emit_leb128_expr(exp
, sign
)
4382 operatorT op
= exp
->X_op
;
4384 if (op
== O_absent
|| op
== O_illegal
)
4386 as_warn (_("zero assumed for missing expression"));
4387 exp
->X_add_number
= 0;
4390 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4392 as_bad (_("floating point number invalid; zero assumed"));
4393 exp
->X_add_number
= 0;
4396 else if (op
== O_register
)
4398 as_warn (_("register value used as expression"));
4402 if (op
== O_constant
)
4404 /* If we've got a constant, emit the thing directly right now. */
4406 valueT value
= exp
->X_add_number
;
4410 size
= sizeof_leb128 (value
, sign
);
4411 p
= frag_more (size
);
4412 output_leb128 (p
, value
, sign
);
4414 else if (op
== O_big
)
4416 /* O_big is a different sort of constant. */
4421 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4422 p
= frag_more (size
);
4423 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4427 /* Otherwise, we have to create a variable sized fragment and
4428 resolve things later. */
4430 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
)0), 0, sign
,
4431 make_expr_symbol (exp
), 0, (char *) NULL
);
4435 /* Parse the .sleb128 and .uleb128 pseudos. */
4445 emit_leb128_expr (&exp
, sign
);
4446 } while (*input_line_pointer
++ == ',');
4448 input_line_pointer
--;
4449 demand_empty_rest_of_line ();
4455 * We read 0 or more ',' separated, double-quoted strings.
4457 * Caller should have checked need_pass_2 is FALSE because we don't check it.
4462 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4463 /* Checks end-of-line. */
4464 register int append_zero
; /* 0: don't append '\0', else 1 */
4466 register unsigned int c
;
4469 #ifdef md_flush_pending_output
4470 md_flush_pending_output ();
4474 * The following awkward logic is to parse ZERO or more strings,
4475 * comma separated. Recall a string expression includes spaces
4476 * before the opening '\"' and spaces after the closing '\"'.
4477 * We fake a leading ',' if there is (supposed to be)
4478 * a 1st, expression. We keep demanding expressions for each
4481 if (is_it_end_of_statement ())
4483 c
= 0; /* Skip loop. */
4484 ++input_line_pointer
; /* Compensate for end of loop. */
4488 c
= ','; /* Do loop. */
4490 while (c
== ',' || c
== '<' || c
== '"')
4493 switch (*input_line_pointer
)
4496 ++input_line_pointer
; /*->1st char of string. */
4497 start
= input_line_pointer
;
4498 while (is_a_char (c
= next_char_of_string ()))
4500 FRAG_APPEND_1_CHAR (c
);
4504 FRAG_APPEND_1_CHAR (0);
4506 know (input_line_pointer
[-1] == '\"');
4510 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4511 will emit .string with a filename in the .debug section
4512 after a sequence of constants. See the comment in
4513 emit_expr for the sequence. emit_expr will set
4514 dwarf_file_string to non-zero if this string might be a
4515 source file name. */
4516 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4517 dwarf_file_string
= 0;
4518 else if (dwarf_file_string
)
4520 c
= input_line_pointer
[-1];
4521 input_line_pointer
[-1] = '\0';
4522 listing_source_file (start
);
4523 input_line_pointer
[-1] = c
;
4530 input_line_pointer
++;
4531 c
= get_single_number ();
4532 FRAG_APPEND_1_CHAR (c
);
4533 if (*input_line_pointer
!= '>')
4535 as_bad (_("Expected <nn>"));
4537 input_line_pointer
++;
4540 input_line_pointer
++;
4544 c
= *input_line_pointer
;
4547 demand_empty_rest_of_line ();
4550 /* FIXME-SOMEDAY: I had trouble here on characters with the
4551 high bits set. We'll probably also have trouble with
4552 multibyte chars, wide chars, etc. Also be careful about
4553 returning values bigger than 1 byte. xoxorich. */
4556 next_char_of_string ()
4558 register unsigned int c
;
4560 c
= *input_line_pointer
++ & CHAR_MASK
;
4568 as_warn (_("Unterminated string: Newline inserted."));
4569 bump_line_counters ();
4572 #ifndef NO_STRING_ESCAPES
4574 switch (c
= *input_line_pointer
++)
4602 break; /* As itself. */
4618 for (i
= 0, number
= 0; isdigit (c
) && i
< 3; c
= *input_line_pointer
++, i
++)
4620 number
= number
* 8 + c
- '0';
4624 --input_line_pointer
;
4633 c
= *input_line_pointer
++;
4634 while (isxdigit (c
))
4637 number
= number
* 16 + c
- '0';
4638 else if (isupper (c
))
4639 number
= number
* 16 + c
- 'A' + 10;
4641 number
= number
* 16 + c
- 'a' + 10;
4642 c
= *input_line_pointer
++;
4645 --input_line_pointer
;
4650 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4651 as_warn (_("Unterminated string: Newline inserted."));
4653 bump_line_counters ();
4658 #ifdef ONLY_STANDARD_ESCAPES
4659 as_bad (_("Bad escaped character in string, '?' assumed"));
4661 #endif /* ONLY_STANDARD_ESCAPES */
4664 } /* switch on escaped char */
4666 #endif /* ! defined (NO_STRING_ESCAPES) */
4670 } /* switch on char */
4672 } /* next_char_of_string() */
4675 get_segmented_expression (expP
)
4676 register expressionS
*expP
;
4678 register segT retval
;
4680 retval
= expression (expP
);
4681 if (expP
->X_op
== O_illegal
4682 || expP
->X_op
== O_absent
4683 || expP
->X_op
== O_big
)
4685 as_bad (_("expected address expression; zero assumed"));
4686 expP
->X_op
= O_constant
;
4687 expP
->X_add_number
= 0;
4688 retval
= absolute_section
;
4694 get_known_segmented_expression (expP
)
4695 register expressionS
*expP
;
4697 register segT retval
;
4699 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4701 /* There is no easy way to extract the undefined symbol from the
4703 if (expP
->X_add_symbol
!= NULL
4704 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4705 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4706 S_GET_NAME (expP
->X_add_symbol
));
4708 as_warn (_("some symbol undefined; zero assumed"));
4709 retval
= absolute_section
;
4710 expP
->X_op
= O_constant
;
4711 expP
->X_add_number
= 0;
4713 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4715 } /* get_known_segmented_expression() */
4718 get_absolute_expression ()
4723 if (exp
.X_op
!= O_constant
)
4725 if (exp
.X_op
!= O_absent
)
4726 as_bad (_("bad or irreducible absolute expression; zero assumed"));
4727 exp
.X_add_number
= 0;
4729 return exp
.X_add_number
;
4732 char /* return terminator */
4733 get_absolute_expression_and_terminator (val_pointer
)
4734 long *val_pointer
; /* return value of expression */
4736 /* FIXME: val_pointer should probably be offsetT *. */
4737 *val_pointer
= (long) get_absolute_expression ();
4738 return (*input_line_pointer
++);
4742 * demand_copy_C_string()
4744 * Like demand_copy_string, but return NULL if the string contains any '\0's.
4745 * Give a warning if that happens.
4748 demand_copy_C_string (len_pointer
)
4753 if ((s
= demand_copy_string (len_pointer
)) != 0)
4757 for (len
= *len_pointer
; len
> 0; len
--)
4764 as_bad (_("This string may not contain \'\\0\'"));
4772 * demand_copy_string()
4774 * Demand string, but return a safe (=private) copy of the string.
4775 * Return NULL if we can't read a string here.
4778 demand_copy_string (lenP
)
4781 register unsigned int c
;
4787 if (*input_line_pointer
== '\"')
4789 input_line_pointer
++; /* Skip opening quote. */
4791 while (is_a_char (c
= next_char_of_string ()))
4793 obstack_1grow (¬es
, c
);
4796 /* JF this next line is so demand_copy_C_string will return a
4797 null terminated string. */
4798 obstack_1grow (¬es
, '\0');
4799 retval
= obstack_finish (¬es
);
4803 as_warn (_("Missing string"));
4805 ignore_rest_of_line ();
4809 } /* demand_copy_string() */
4812 * is_it_end_of_statement()
4814 * In: Input_line_pointer->next character.
4816 * Do: Skip input_line_pointer over all whitespace.
4818 * Out: 1 if input_line_pointer->end-of-line.
4821 is_it_end_of_statement ()
4824 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4825 } /* is_it_end_of_statement() */
4828 equals (sym_name
, reassign
)
4832 register symbolS
*symbolP
; /* symbol we are working with */
4836 input_line_pointer
++;
4837 if (*input_line_pointer
== '=')
4838 input_line_pointer
++;
4840 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4841 input_line_pointer
++;
4844 stop
= mri_comment_field (&stopc
);
4846 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4848 /* Turn '. = mumble' into a .org mumble */
4849 register segT segment
;
4852 segment
= get_known_segmented_expression (&exp
);
4854 do_org (segment
, &exp
, 0);
4858 symbolP
= symbol_find_or_make (sym_name
);
4859 /* Permit register names to be redefined. */
4861 && S_IS_DEFINED (symbolP
)
4862 && S_GET_SEGMENT (symbolP
) != reg_section
)
4863 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
4864 pseudo_set (symbolP
);
4869 ignore_rest_of_line (); /* check garbage after the expression */
4870 mri_comment_end (stop
, stopc
);
4874 /* .include -- include a file at this point. */
4879 int arg ATTRIBUTE_UNUSED
;
4887 if (! flag_m68k_mri
)
4889 filename
= demand_copy_string (&i
);
4890 if (filename
== NULL
)
4892 /* demand_copy_string has already printed an error and
4893 called ignore_rest_of_line. */
4901 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
4902 && *input_line_pointer
!= ' '
4903 && *input_line_pointer
!= '\t')
4905 obstack_1grow (¬es
, *input_line_pointer
);
4906 ++input_line_pointer
;
4909 obstack_1grow (¬es
, '\0');
4910 filename
= obstack_finish (¬es
);
4911 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
4912 ++input_line_pointer
;
4914 demand_empty_rest_of_line ();
4915 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
4916 for (i
= 0; i
< include_dir_count
; i
++)
4918 strcpy (path
, include_dirs
[i
]);
4920 strcat (path
, filename
);
4921 if (0 != (try = fopen (path
, "r")))
4930 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
4931 register_dependency (path
);
4932 newbuf
= input_scrub_include_file (path
, input_line_pointer
);
4933 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
4937 add_include_dir (path
)
4942 if (include_dir_count
== 0)
4944 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
4945 include_dirs
[0] = "."; /* Current dir */
4946 include_dir_count
= 2;
4950 include_dir_count
++;
4951 include_dirs
= (char **) realloc (include_dirs
,
4952 include_dir_count
* sizeof (*include_dirs
));
4955 include_dirs
[include_dir_count
- 1] = path
; /* New one */
4958 if (i
> include_dir_maxlen
)
4959 include_dir_maxlen
= i
;
4960 } /* add_include_dir() */
4962 /* Output debugging information to denote the source file. */
4965 generate_file_debug ()
4967 if (debug_type
== DEBUG_STABS
)
4968 stabs_generate_asm_file ();
4971 /* Output line number debugging information for the current source line. */
4974 generate_lineno_debug ()
4976 #ifdef ECOFF_DEBUGGING
4977 /* ECOFF assemblers automatically generate debugging information.
4978 FIXME: This should probably be handled elsewhere. */
4979 if (debug_type
== DEBUG_UNSPECIFIED
)
4981 if (ECOFF_DEBUGGING
&& ecoff_no_current_file ())
4982 debug_type
= DEBUG_ECOFF
;
4984 debug_type
= DEBUG_NONE
;
4990 case DEBUG_UNSPECIFIED
:
4994 stabs_generate_asm_lineno ();
4997 ecoff_generate_asm_lineno ();
5006 /* Output debugging information to mark a function entry point or end point.
5007 END_P is zero for .func, and non-zero for .endfunc. */
5013 do_s_func (end_p
, NULL
);
5016 /* Subroutine of s_func so targets can choose a different default prefix.
5017 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5020 do_s_func (end_p
, default_prefix
)
5022 const char *default_prefix
;
5024 /* Record the current function so that we can issue an error message for
5025 misplaced .func,.endfunc, and also so that .endfunc needs no
5027 static char *current_name
;
5028 static char *current_label
;
5032 if (current_name
== NULL
)
5034 as_bad (_("missing .func"));
5035 ignore_rest_of_line ();
5039 if (debug_type
== DEBUG_STABS
)
5040 stabs_generate_asm_endfunc (current_name
, current_label
);
5042 current_name
= current_label
= NULL
;
5049 if (current_name
!= NULL
)
5051 as_bad (_(".endfunc missing for previous .func"));
5052 ignore_rest_of_line ();
5056 name
= input_line_pointer
;
5057 delim1
= get_symbol_end ();
5058 name
= xstrdup (name
);
5059 *input_line_pointer
= delim1
;
5061 if (*input_line_pointer
!= ',')
5064 asprintf (&label
, "%s%s", default_prefix
, name
);
5067 char leading_char
= 0;
5068 #ifdef BFD_ASSEMBLER
5069 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5071 /* Missing entry point, use function's name with the leading
5074 asprintf (&label
, "%c%s", leading_char
, name
);
5081 ++input_line_pointer
;
5083 label
= input_line_pointer
;
5084 delim2
= get_symbol_end ();
5085 label
= xstrdup (label
);
5086 *input_line_pointer
= delim2
;
5089 if (debug_type
== DEBUG_STABS
)
5090 stabs_generate_asm_func (name
, label
);
5092 current_name
= name
;
5093 current_label
= label
;
5096 demand_empty_rest_of_line ();
5101 int arg ATTRIBUTE_UNUSED
;
5103 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5105 ++input_line_pointer
;
5107 ++input_line_pointer
;
5112 read_print_statistics (file
)
5115 hash_print_statistics (file
, "pseudo-op table", po_hash
);