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 /* The NOP_OPCODE is for the alignment fill value.
57 * fill it a nop instruction so that the disassembler does not choke
61 #define NOP_OPCODE 0x00
64 char *input_line_pointer
; /*->next char of source file to parse. */
66 #if BITS_PER_CHAR != 8
67 /* The following table is indexed by[(char)] and will break if
68 a char does not have exactly 256 states (hopefully 0:255!)! */
73 /* The m88k unfortunately uses @ as a label beginner. */
78 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
83 /* The Delta 68k assembler permits % inside label names. */
88 /* The PowerPC Windows NT assemblers permits ? inside label names. */
97 /* The a29k assembler does not permits labels to start with $. */
102 /* The Delta 68k assembler permits ~ at start of label names. */
106 /* used by is_... macros. our ctype[] */
109 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
111 0, 0, 0, LEX_HASH
, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
112 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
113 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
114 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
115 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
116 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
117 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
118 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
119 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
120 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
121 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
122 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
123 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
124 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
130 * Out: 1 if this character ends a line.
133 char is_end_of_line
[256] =
136 99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, 99, Z_
, Z_
, /* @abcdefghijklmno */
138 99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, Z_
, Z_
, Z_
, /* @abcdefghijklmno */
140 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
142 Z_
,99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* _!"#$%&'()*+,-./ */
143 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* 0123456789:;<=>? */
145 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
146 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, Z_
, Z_
, /* 0123456789:;<=>? */
148 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
149 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
150 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
151 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
152 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
153 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
154 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
155 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
156 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
160 /* Functions private to this file. */
162 static char *buffer
; /* 1st char of each buffer of lines is here. */
163 static char *buffer_limit
; /*->1 + last char in buffer. */
165 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1 in the
166 tc-<CPU>.h file. See the "Porting GAS" section of the internals manual. */
167 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
169 static char *old_buffer
; /* JF a hack */
170 static char *old_input
;
171 static char *old_limit
;
173 /* Variables for handling include file directory table. */
175 char **include_dirs
; /* Table of pointers to directories to
176 search for .include's */
177 int include_dir_count
; /* How many are in the table */
178 int include_dir_maxlen
= 1;/* Length of longest in table */
180 #ifndef WORKING_DOT_WORD
181 struct broken_word
*broken_words
;
182 int new_broken_words
;
185 /* The current offset into the absolute section. We don't try to
186 build frags in the absolute section, since no data can be stored
187 there. We just keep track of the current offset. */
188 addressT abs_section_offset
;
190 /* If this line had an MRI style label, it is stored in this variable.
191 This is used by some of the MRI pseudo-ops. */
194 /* This global variable is used to support MRI common sections. We
195 translate such sections into a common symbol. This variable is
196 non-NULL when we are in an MRI common section. */
197 symbolS
*mri_common_symbol
;
199 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
200 need to align to an even byte boundary unless the next pseudo-op is
201 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
203 static int mri_pending_align
;
207 /* This variable is set to be non-zero if the next string we see might
208 be the name of the source file in DWARF debugging information. See
209 the comment in emit_expr for the format we look for. */
210 static int dwarf_file_string
;
214 static void cons_worker
PARAMS ((int, int));
215 static int scrub_from_string
PARAMS ((char *, int));
216 static void do_align
PARAMS ((int, char *, int, int));
217 static void s_align
PARAMS ((int, int));
218 static void s_lcomm_internal
PARAMS ((int, int));
219 static int hex_float
PARAMS ((int, char *));
220 static inline int sizeof_sleb128
PARAMS ((offsetT
));
221 static inline int sizeof_uleb128
PARAMS ((valueT
));
222 static inline int output_sleb128
PARAMS ((char *, offsetT
));
223 static inline int output_uleb128
PARAMS ((char *, valueT
));
224 static inline int output_big_sleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
225 static inline int output_big_uleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
226 static int output_big_leb128
PARAMS ((char *, LITTLENUM_TYPE
*, int, int));
227 static void do_org
PARAMS ((segT
, expressionS
*, int));
228 char *demand_copy_string
PARAMS ((int *lenP
));
229 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
230 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
231 static void pobegin
PARAMS ((void));
232 static int get_line_sb
PARAMS ((sb
*));
233 static void generate_file_debug
PARAMS ((void));
242 obj_read_begin_hook ();
244 /* Something close -- but not too close -- to a multiple of 1024.
245 The debugging malloc I'm using has 24 bytes of overhead. */
246 obstack_begin (¬es
, chunksize
);
247 obstack_begin (&cond_obstack
, chunksize
);
249 /* Use machine dependent syntax */
250 for (p
= line_separator_chars
; *p
; p
++)
251 is_end_of_line
[(unsigned char) *p
] = 1;
252 /* Use more. FIXME-SOMEDAY. */
258 /* set up pseudo-op tables */
260 static struct hash_control
*po_hash
;
262 static const pseudo_typeS potable
[] =
264 {"abort", s_abort
, 0},
265 {"align", s_align_ptwo
, 0},
266 {"ascii", stringer
, 0},
267 {"asciz", stringer
, 1},
268 {"balign", s_align_bytes
, 0},
269 {"balignw", s_align_bytes
, -2},
270 {"balignl", s_align_bytes
, -4},
274 {"common", s_mri_common
, 0},
275 {"common.s", s_mri_common
, 1},
279 {"dc.d", float_cons
, 'd'},
281 {"dc.s", float_cons
, 'f'},
283 {"dc.x", float_cons
, 'x'},
285 {"dcb.b", s_space
, 1},
286 {"dcb.d", s_float_space
, 'd'},
287 {"dcb.l", s_space
, 4},
288 {"dcb.s", s_float_space
, 'f'},
289 {"dcb.w", s_space
, 2},
290 {"dcb.x", s_float_space
, 'x'},
292 {"ds.b", s_space
, 1},
293 {"ds.d", s_space
, 8},
294 {"ds.l", s_space
, 4},
295 {"ds.p", s_space
, 12},
296 {"ds.s", s_space
, 4},
297 {"ds.w", s_space
, 2},
298 {"ds.x", s_space
, 12},
299 {"debug", s_ignore
, 0},
304 {"double", float_cons
, 'd'},
306 {"eject", listing_eject
, 0}, /* Formfeed listing */
308 {"elsec", s_else
, 0},
309 {"elseif", s_elseif
, (int) O_ne
},
311 {"endc", s_endif
, 0},
312 {"endfunc", s_func
, 1},
313 {"endif", s_endif
, 0},
318 {"exitm", s_mexit
, 0},
320 {"extern", s_ignore
, 0}, /* We treat all undef as ext */
321 {"appfile", s_app_file
, 1},
322 {"appline", s_app_line
, 0},
324 {"file", s_app_file
, 0},
326 {"float", float_cons
, 'f'},
327 {"format", s_ignore
, 0},
329 {"global", s_globl
, 0},
330 {"globl", s_globl
, 0},
332 {"if", s_if
, (int) O_ne
},
334 {"ifdef", s_ifdef
, 0},
335 {"ifeq", s_if
, (int) O_eq
},
336 {"ifeqs", s_ifeqs
, 0},
337 {"ifge", s_if
, (int) O_ge
},
338 {"ifgt", s_if
, (int) O_gt
},
339 {"ifle", s_if
, (int) O_le
},
340 {"iflt", s_if
, (int) O_lt
},
342 {"ifndef", s_ifdef
, 1},
343 {"ifne", s_if
, (int) O_ne
},
344 {"ifnes", s_ifeqs
, 1},
345 {"ifnotdef", s_ifdef
, 1},
346 {"include", s_include
, 0},
352 {"lcomm", s_lcomm
, 0},
353 {"lflags", listing_flags
, 0}, /* Listing flags */
354 {"linkonce", s_linkonce
, 0},
355 {"list", listing_list
, 1}, /* Turn listing on */
356 {"llen", listing_psize
, 1},
359 {"macro", s_macro
, 0},
360 {"mexit", s_mexit
, 0},
362 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
363 {"name", s_ignore
, 0},
364 {"noformat", s_ignore
, 0},
365 {"nolist", listing_list
, 0}, /* Turn listing off */
366 {"nopage", listing_nopage
, 0},
368 {"offset", s_struct
, 0},
370 {"p2align", s_align_ptwo
, 0},
371 {"p2alignw", s_align_ptwo
, -2},
372 {"p2alignl", s_align_ptwo
, -4},
373 {"page", listing_eject
, 0},
374 {"plen", listing_psize
, 0},
375 {"print", s_print
, 0},
376 {"psize", listing_psize
, 0}, /* set paper size */
377 {"purgem", s_purgem
, 0},
382 {"sbttl", listing_title
, 1}, /* Subtitle of listing */
387 {"single", float_cons
, 'f'},
389 {"space", s_space
, 0},
390 {"skip", s_space
, 0},
391 {"sleb128", s_leb128
, 1},
392 {"spc", s_ignore
, 0},
393 {"stabd", s_stab
, 'd'},
394 {"stabn", s_stab
, 'n'},
395 {"stabs", s_stab
, 's'},
396 {"string", stringer
, 1},
397 {"struct", s_struct
, 0},
401 /* This is for gcc to use. It's only just been added (2/94), so gcc
402 won't be able to use it for a while -- probably a year or more.
403 But once this has been released, check with gcc maintainers
404 before deleting it or even changing the spelling. */
405 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
406 /* If we're folding case -- done for some targets, not necessarily
407 all -- the above string in an input file will be converted to
408 this one. Match it either way... */
409 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
411 {"title", listing_title
, 0}, /* Listing title */
412 {"ttl", listing_title
, 0},
414 {"uleb128", s_leb128
, 0},
418 {"xdef", s_globl
, 0},
419 {"xref", s_ignore
, 0},
420 {"xstabs", s_xstab
, 's'},
422 {"zero", s_space
, 0},
423 {NULL
, NULL
, 0} /* end sentinel */
426 static int pop_override_ok
= 0;
427 static const char *pop_table_name
;
431 const pseudo_typeS
*table
;
434 const pseudo_typeS
*pop
;
435 for (pop
= table
; pop
->poc_name
; pop
++)
437 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
438 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
439 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
444 #ifndef md_pop_insert
445 #define md_pop_insert() pop_insert(md_pseudo_table)
448 #ifndef obj_pop_insert
449 #define obj_pop_insert() pop_insert(obj_pseudo_table)
455 po_hash
= hash_new ();
457 /* Do the target-specific pseudo ops. */
458 pop_table_name
= "md";
461 /* Now object specific. Skip any that were in the target table. */
462 pop_table_name
= "obj";
466 /* Now portable ones. Skip any that we've seen already. */
467 pop_table_name
= "standard";
468 pop_insert (potable
);
471 #define HANDLE_CONDITIONAL_ASSEMBLY() \
472 if (ignore_input ()) \
474 while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \
475 if (input_line_pointer == buffer_limit) \
481 /* This function is used when scrubbing the characters between #APP
484 static char *scrub_string
;
485 static char *scrub_string_end
;
488 scrub_from_string (buf
, buflen
)
494 copy
= scrub_string_end
- scrub_string
;
497 memcpy (buf
, scrub_string
, copy
);
498 scrub_string
+= copy
;
502 /* read_a_source_file()
504 * We read the file, putting things into a web that
505 * represents what we have been reading.
508 read_a_source_file (name
)
512 register char *s
; /* string of symbol, '\0' appended */
516 buffer
= input_scrub_new_file (name
);
519 listing_newline (NULL
);
520 register_dependency (name
);
522 /* Generate debugging information before we've read anything in to denote
523 this file as the "main" source file and not a subordinate one
524 (e.g. N_SO vs N_SOL in stabs). */
525 generate_file_debug ();
527 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
528 { /* We have another line to parse. */
529 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
530 contin
: /* JF this goto is my fault I admit it.
531 Someone brave please re-write the whole
532 input section here? Pleeze??? */
533 while (input_line_pointer
< buffer_limit
)
535 /* We have more of this buffer to parse. */
538 * We now have input_line_pointer->1st char of next line.
539 * If input_line_pointer [-1] == '\n' then we just
540 * scanned another line: so bump line counters.
542 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
544 #ifdef md_start_line_hook
545 md_start_line_hook ();
548 if (input_line_pointer
[-1] == '\n')
549 bump_line_counters ();
553 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
555 /* Text at the start of a line must be a label, we
556 run down and stick a colon in. */
557 if (is_name_beginner (*input_line_pointer
))
559 char *line_start
= input_line_pointer
;
564 HANDLE_CONDITIONAL_ASSEMBLY ();
566 c
= get_symbol_end ();
568 /* In MRI mode, the EQU and MACRO pseudoops must
569 be handled specially. */
573 char *rest
= input_line_pointer
+ 1;
577 if (*rest
== ' ' || *rest
== '\t')
579 if ((strncasecmp (rest
, "EQU", 3) == 0
580 || strncasecmp (rest
, "SET", 3) == 0)
581 && (rest
[3] == ' ' || rest
[3] == '\t'))
583 input_line_pointer
= rest
+ 3;
585 strncasecmp (rest
, "SET", 3) == 0);
588 if (strncasecmp (rest
, "MACRO", 5) == 0
591 || is_end_of_line
[(unsigned char) rest
[5]]))
595 /* In MRI mode, we need to handle the MACRO
596 pseudo-op specially: we don't want to put the
597 symbol in the symbol table. */
599 #ifdef TC_START_LABEL_WITHOUT_COLON
600 && TC_START_LABEL_WITHOUT_COLON(c
,
604 line_label
= colon (line_start
);
606 line_label
= symbol_create (line_start
,
611 *input_line_pointer
= c
;
613 input_line_pointer
++;
619 * We are at the begining of a line, or similar place.
620 * We expect a well-formed assembler statement.
621 * A "symbol-name:" is a statement.
623 * Depending on what compiler is used, the order of these tests
624 * may vary to catch most common case 1st.
625 * Each test is independent of all other tests at the (top) level.
626 * PLEASE make a compiler that doesn't use this assembler.
627 * It is crufty to waste a compiler's time encoding things for this
628 * assembler, which then wastes more time decoding it.
629 * (And communicating via (linear) files is silly!
630 * If you must pass stuff, please pass a tree!)
632 if ((c
= *input_line_pointer
++) == '\t'
637 c
= *input_line_pointer
++;
639 know (c
!= ' '); /* No further leading whitespace. */
642 /* If listing is on, and we are expanding a macro, then give
643 the listing code the contents of the expanded line. */
646 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
651 /* Find the end of the current expanded macro line. */
652 for (s
= input_line_pointer
-1; *s
; ++s
)
653 if (is_end_of_line
[(unsigned char) *s
])
656 /* Copy it for safe keeping. Also give an indication of
657 how much macro nesting is involved at this point. */
658 len
= s
- (input_line_pointer
-1);
659 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
660 memset (copy
, '>', macro_nest
);
661 copy
[macro_nest
] = ' ';
662 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
-1, len
);
663 copy
[macro_nest
+1+len
] = '\0';
665 /* Install the line with the listing facility. */
666 listing_newline (copy
);
669 listing_newline (NULL
);
674 * C is the 1st significant character.
675 * Input_line_pointer points after that character.
677 if (is_name_beginner (c
))
679 /* want user-defined label or pseudo/opcode */
680 HANDLE_CONDITIONAL_ASSEMBLY ();
682 s
= --input_line_pointer
;
683 c
= get_symbol_end (); /* name's delimiter */
685 * C is character after symbol.
686 * That character's place in the input line is now '\0'.
687 * S points to the beginning of the symbol.
688 * [In case of pseudo-op, s->'.'.]
689 * Input_line_pointer->'\0' where c was.
691 if (TC_START_LABEL(c
, input_line_pointer
))
695 char *rest
= input_line_pointer
+ 1;
697 /* In MRI mode, \tsym: set 0 is permitted. */
701 if (*rest
== ' ' || *rest
== '\t')
703 if ((strncasecmp (rest
, "EQU", 3) == 0
704 || strncasecmp (rest
, "SET", 3) == 0)
705 && (rest
[3] == ' ' || rest
[3] == '\t'))
707 input_line_pointer
= rest
+ 3;
713 line_label
= colon (s
); /* user-defined label */
714 *input_line_pointer
++ = ':'; /* Put ':' back for error messages' sake. */
715 /* Input_line_pointer->after ':'. */
721 || ((c
== ' ' || c
== '\t')
722 && input_line_pointer
[1] == '='
723 #ifdef TC_EQUAL_IN_INSN
724 && ! TC_EQUAL_IN_INSN (c
, input_line_pointer
)
729 demand_empty_rest_of_line ();
732 { /* expect pseudo-op or machine instruction */
735 #define IGNORE_OPCODE_CASE
736 #ifdef IGNORE_OPCODE_CASE
741 if (isupper ((unsigned char) *s2
))
748 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
750 /* The MRI assembler and the m88k use pseudo-ops
752 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
753 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
758 || (! flag_m68k_mri
&& *s
== '.'))
763 * WARNING: c has next char, which may be end-of-line.
764 * We lookup the pseudo-op table with s+1 because we
765 * already know that the pseudo-op begins with a '.'.
769 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
771 /* In MRI mode, we may need to insert an
772 automatic alignment directive. What a hack
774 if (mri_pending_align
776 || ! ((pop
->poc_handler
== cons
777 && pop
->poc_val
== 1)
778 || (pop
->poc_handler
== s_space
779 && pop
->poc_val
== 1)
780 #ifdef tc_conditional_pseudoop
781 || tc_conditional_pseudoop (pop
)
783 || pop
->poc_handler
== s_if
784 || pop
->poc_handler
== s_ifdef
785 || pop
->poc_handler
== s_ifc
786 || pop
->poc_handler
== s_ifeqs
787 || pop
->poc_handler
== s_else
788 || pop
->poc_handler
== s_endif
789 || pop
->poc_handler
== s_globl
790 || pop
->poc_handler
== s_ignore
)))
792 do_align (1, (char *) NULL
, 0, 0);
793 mri_pending_align
= 0;
794 if (line_label
!= NULL
)
796 symbol_set_frag (line_label
, frag_now
);
797 S_SET_VALUE (line_label
, frag_now_fix ());
801 /* Print the error msg now, while we still can */
804 as_bad (_("Unknown pseudo-op: `%s'"), s
);
805 *input_line_pointer
= c
;
810 /* Put it back for error messages etc. */
811 *input_line_pointer
= c
;
812 /* The following skip of whitespace is compulsory.
813 A well shaped space is sometimes all that separates
814 keyword from operands. */
815 if (c
== ' ' || c
== '\t')
816 input_line_pointer
++;
818 * Input_line is restored.
819 * Input_line_pointer->1st non-blank char
820 * after pseudo-operation.
822 (*pop
->poc_handler
) (pop
->poc_val
);
824 /* If that was .end, just get out now. */
825 if (pop
->poc_handler
== s_end
)
831 #ifdef QUOTES_IN_INSN
835 /* WARNING: c has char, which may be end-of-line. */
836 /* Also: input_line_pointer->`\0` where c was. */
837 *input_line_pointer
= c
;
838 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
840 #ifdef TC_EOL_IN_INSN
841 || TC_EOL_IN_INSN (input_line_pointer
)
845 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
847 #ifdef QUOTES_IN_INSN
850 else if (*input_line_pointer
== '"')
852 else if (*input_line_pointer
== '\\')
855 input_line_pointer
++;
858 c
= *input_line_pointer
;
859 *input_line_pointer
= '\0';
861 generate_lineno_debug ();
868 if (check_macro (s
, &out
, '\0', &err
))
872 *input_line_pointer
++ = c
;
873 input_scrub_include_sb (&out
,
877 input_scrub_next_buffer (&input_line_pointer
);
882 if (mri_pending_align
)
884 do_align (1, (char *) NULL
, 0, 0);
885 mri_pending_align
= 0;
886 if (line_label
!= NULL
)
888 symbol_set_frag (line_label
, frag_now
);
889 S_SET_VALUE (line_label
, frag_now_fix ());
893 md_assemble (s
); /* Assemble 1 instruction. */
895 *input_line_pointer
++ = c
;
897 /* We resume loop AFTER the end-of-line from
902 } /* if (is_name_beginner(c) */
905 /* Empty statement? */
906 if (is_end_of_line
[(unsigned char) c
])
909 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
910 && isdigit ((unsigned char) c
))
912 /* local label ("4:") */
913 char *backup
= input_line_pointer
;
915 HANDLE_CONDITIONAL_ASSEMBLY ();
919 while (isdigit ((unsigned char) *input_line_pointer
))
921 temp
= (temp
* 10) + *input_line_pointer
- '0';
922 ++input_line_pointer
;
923 } /* read the whole number */
925 if (LOCAL_LABELS_DOLLAR
926 && *input_line_pointer
== '$'
927 && *(input_line_pointer
+ 1) == ':')
929 input_line_pointer
+= 2;
931 if (dollar_label_defined (temp
))
933 as_fatal (_("label \"%d$\" redefined"), temp
);
936 define_dollar_label (temp
);
937 colon (dollar_label_name (temp
, 0));
942 && *input_line_pointer
++ == ':')
944 fb_label_instance_inc (temp
);
945 colon (fb_label_name (temp
, 0));
949 input_line_pointer
= backup
;
950 } /* local label ("4:") */
952 if (c
&& strchr (line_comment_chars
, c
))
953 { /* Its a comment. Better say APP or NO_APP */
957 unsigned int new_length
;
960 bump_line_counters ();
961 s
= input_line_pointer
;
962 if (strncmp (s
, "APP\n", 4))
963 continue; /* We ignore it */
966 ends
= strstr (s
, "#NO_APP\n");
970 unsigned int tmp_len
;
973 /* The end of the #APP wasn't in this buffer. We
974 keep reading in buffers until we find the #NO_APP
975 that goes with this #APP There is one. The specs
977 tmp_len
= buffer_limit
- s
;
978 tmp_buf
= xmalloc (tmp_len
+ 1);
979 memcpy (tmp_buf
, s
, tmp_len
);
982 new_tmp
= input_scrub_next_buffer (&buffer
);
986 buffer_limit
= new_tmp
;
987 input_line_pointer
= buffer
;
988 ends
= strstr (buffer
, "#NO_APP\n");
992 num
= buffer_limit
- buffer
;
994 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
995 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
1000 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1008 input_line_pointer
= ends
+ 8;
1012 scrub_string_end
= ends
;
1014 new_length
= ends
- s
;
1015 new_buf
= (char *) xmalloc (new_length
);
1022 space
= (new_buf
+ new_length
) - new_tmp
;
1023 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1031 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1032 new_tmp
= new_buf
+ new_length
;
1038 old_buffer
= buffer
;
1039 old_input
= input_line_pointer
;
1040 old_limit
= buffer_limit
;
1042 input_line_pointer
= new_buf
;
1043 buffer_limit
= new_tmp
;
1047 HANDLE_CONDITIONAL_ASSEMBLY ();
1049 #ifdef tc_unrecognized_line
1050 if (tc_unrecognized_line (c
))
1054 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
1055 input_line_pointer
--; /* Report unknown char as ignored. */
1056 ignore_rest_of_line ();
1057 } /* while (input_line_pointer<buffer_limit) */
1059 #ifdef md_after_pass_hook
1060 md_after_pass_hook ();
1066 bump_line_counters ();
1069 buffer
= old_buffer
;
1070 input_line_pointer
= old_input
;
1071 buffer_limit
= old_limit
;
1076 } /* while (more buffers to scan) */
1083 input_scrub_close (); /* Close the input file */
1086 /* For most MRI pseudo-ops, the line actually ends at the first
1087 nonquoted space. This function looks for that point, stuffs a null
1088 in, and sets *STOPCP to the character that used to be there, and
1089 returns the location.
1091 Until I hear otherwise, I am going to assume that this is only true
1092 for the m68k MRI assembler. */
1095 mri_comment_field (stopcp
)
1103 know (flag_m68k_mri
);
1105 for (s
= input_line_pointer
;
1106 ((! is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1111 inquote
= ! inquote
;
1121 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
1131 /* Skip to the end of an MRI comment field. */
1134 mri_comment_end (stop
, stopc
)
1140 input_line_pointer
= stop
;
1142 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1143 ++input_line_pointer
;
1148 int ignore ATTRIBUTE_UNUSED
;
1150 as_fatal (_(".abort detected. Abandoning ship."));
1153 /* Guts of .align directive. N is the power of two to which to align.
1154 FILL may be NULL, or it may point to the bytes of the fill pattern.
1155 LEN is the length of whatever FILL points to, if anything. MAX is
1156 the maximum number of characters to skip when doing the alignment,
1157 or 0 if there is no maximum. */
1160 do_align (n
, fill
, len
, max
)
1169 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1174 if (subseg_text_p (now_seg
))
1175 default_fill
= NOP_OPCODE
;
1178 fill
= &default_fill
;
1182 /* Only make a frag if we HAVE to. . . */
1183 if (n
!= 0 && !need_pass_2
)
1186 frag_align (n
, *fill
, max
);
1188 frag_align_pattern (n
, fill
, len
, max
);
1192 just_record_alignment
:
1195 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1198 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1199 (in bytes). A negative ARG is the negative of the length of the
1200 fill pattern. BYTES_P is non-zero if the alignment value should be
1201 interpreted as the byte boundary, rather than the power of 2. */
1204 s_align (arg
, bytes_p
)
1208 register unsigned int align
;
1216 stop
= mri_comment_field (&stopc
);
1218 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1223 align
= arg
; /* Default value from pseudo-op table */
1227 align
= get_absolute_expression ();
1233 /* Convert to a power of 2. */
1238 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1241 as_bad (_("Alignment not a power of 2"));
1249 as_bad (_("Alignment too large: %u assumed"), align
);
1252 if (*input_line_pointer
!= ',')
1259 ++input_line_pointer
;
1260 if (*input_line_pointer
== ',')
1264 fill
= get_absolute_expression ();
1269 if (*input_line_pointer
!= ',')
1273 ++input_line_pointer
;
1274 max
= get_absolute_expression ();
1281 as_warn (_("expected fill pattern missing"));
1282 do_align (align
, (char *) NULL
, 0, max
);
1297 do_align (align
, &fill_char
, fill_len
, max
);
1303 if ((size_t) fill_len
> sizeof ab
)
1305 md_number_to_chars (ab
, fill
, fill_len
);
1306 do_align (align
, ab
, fill_len
, max
);
1310 demand_empty_rest_of_line ();
1313 mri_comment_end (stop
, stopc
);
1316 /* Handle the .align pseudo-op on machines where ".align 4" means
1317 align to a 4 byte boundary. */
1326 /* Handle the .align pseudo-op on machines where ".align 4" means align
1327 to a 2**4 boundary. */
1338 int ignore ATTRIBUTE_UNUSED
;
1340 register char *name
;
1344 register symbolS
*symbolP
;
1349 stop
= mri_comment_field (&stopc
);
1351 name
= input_line_pointer
;
1352 c
= get_symbol_end ();
1353 /* just after name is now '\0' */
1354 p
= input_line_pointer
;
1357 if (*input_line_pointer
!= ',')
1359 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1360 ignore_rest_of_line ();
1362 mri_comment_end (stop
, stopc
);
1365 input_line_pointer
++; /* skip ',' */
1366 if ((temp
= get_absolute_expression ()) < 0)
1368 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
1369 ignore_rest_of_line ();
1371 mri_comment_end (stop
, stopc
);
1375 symbolP
= symbol_find_or_make (name
);
1377 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
1379 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1380 S_GET_NAME (symbolP
));
1381 ignore_rest_of_line ();
1383 mri_comment_end (stop
, stopc
);
1386 if (S_GET_VALUE (symbolP
))
1388 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1389 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
1390 S_GET_NAME (symbolP
),
1391 (long) S_GET_VALUE (symbolP
),
1396 S_SET_VALUE (symbolP
, (valueT
) temp
);
1397 S_SET_EXTERNAL (symbolP
);
1401 extern int flag_one
;
1402 if ( (!temp
) || !flag_one
)
1403 S_GET_OTHER(symbolP
) = const_flag
;
1405 #endif /* not OBJ_VMS */
1406 know (symbolP
->sy_frag
== &zero_address_frag
);
1408 demand_empty_rest_of_line ();
1411 mri_comment_end (stop
, stopc
);
1414 /* The MRI COMMON pseudo-op. We handle this by creating a common
1415 symbol with the appropriate name. We make s_space do the right
1416 thing by increasing the size. */
1419 s_mri_common (small
)
1420 int small ATTRIBUTE_UNUSED
;
1436 stop
= mri_comment_field (&stopc
);
1440 name
= input_line_pointer
;
1441 if (! isdigit ((unsigned char) *name
))
1442 c
= get_symbol_end ();
1447 ++input_line_pointer
;
1449 while (isdigit ((unsigned char) *input_line_pointer
));
1450 c
= *input_line_pointer
;
1451 *input_line_pointer
= '\0';
1453 if (line_label
!= NULL
)
1455 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1456 + (input_line_pointer
- name
)
1458 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1463 sym
= symbol_find_or_make (name
);
1464 *input_line_pointer
= c
;
1468 if (*input_line_pointer
!= ',')
1472 ++input_line_pointer
;
1473 align
= get_absolute_expression ();
1476 if (S_IS_DEFINED (sym
) && ! S_IS_COMMON (sym
))
1478 as_bad (_("attempt to re-define symbol `%s'"), S_GET_NAME (sym
));
1479 ignore_rest_of_line ();
1480 mri_comment_end (stop
, stopc
);
1484 S_SET_EXTERNAL (sym
);
1485 mri_common_symbol
= sym
;
1489 S_SET_ALIGN (sym
, align
);
1492 if (line_label
!= NULL
)
1495 exp
.X_op
= O_symbol
;
1496 exp
.X_add_symbol
= sym
;
1497 exp
.X_add_number
= 0;
1498 symbol_set_value_expression (line_label
, &exp
);
1499 symbol_set_frag (line_label
, &zero_address_frag
);
1500 S_SET_SEGMENT (line_label
, expr_section
);
1503 /* FIXME: We just ignore the small argument, which distinguishes
1504 COMMON and COMMON.S. I don't know what we can do about it. */
1506 /* Ignore the type and hptype. */
1507 if (*input_line_pointer
== ',')
1508 input_line_pointer
+= 2;
1509 if (*input_line_pointer
== ',')
1510 input_line_pointer
+= 2;
1512 demand_empty_rest_of_line ();
1514 mri_comment_end (stop
, stopc
);
1519 int ignore ATTRIBUTE_UNUSED
;
1524 temp
= get_absolute_expression ();
1525 if (flag_readonly_data_in_text
)
1527 section
= text_section
;
1531 section
= data_section
;
1533 subseg_set (section
, (subsegT
) temp
);
1538 demand_empty_rest_of_line ();
1541 /* Handle the .appfile pseudo-op. This is automatically generated by
1542 do_scrub_chars when a preprocessor # line comment is seen with a
1543 file name. This default definition may be overridden by the object
1544 or CPU specific pseudo-ops. This function is also the default
1545 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1549 s_app_file (appfile
)
1555 /* Some assemblers tolerate immediately following '"' */
1556 if ((s
= demand_copy_string (&length
)) != 0)
1558 /* If this is a fake .appfile, a fake newline was inserted into
1559 the buffer. Passing -2 to new_logical_line tells it to
1562 = (! new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1564 /* In MRI mode, the preprocessor may have inserted an extraneous
1567 && *input_line_pointer
== '\''
1568 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1569 ++input_line_pointer
;
1571 demand_empty_rest_of_line ();
1576 listing_source_file (s
);
1578 register_dependency (s
);
1586 /* Handle the .appline pseudo-op. This is automatically generated by
1587 do_scrub_chars when a preprocessor # line comment is seen. This
1588 default definition may be overridden by the object or CPU specific
1593 int ignore ATTRIBUTE_UNUSED
;
1597 /* The given number is that of the next line. */
1598 l
= get_absolute_expression () - 1;
1600 /* Some of the back ends can't deal with non-positive line numbers.
1601 Besides, it's silly. */
1602 as_warn (_("Line numbers must be positive; line number %d rejected."), l
+1);
1605 new_logical_line ((char *) NULL
, l
);
1608 listing_source_line (l
);
1611 demand_empty_rest_of_line ();
1614 /* Handle the .end pseudo-op. Actually, the real work is done in
1615 read_a_source_file. */
1619 int ignore ATTRIBUTE_UNUSED
;
1623 /* The MRI assembler permits the start symbol to follow .end,
1624 but we don't support that. */
1626 if (! is_end_of_line
[(unsigned char) *input_line_pointer
]
1627 && *input_line_pointer
!= '*'
1628 && *input_line_pointer
!= '!')
1629 as_warn (_("start address not supported"));
1633 /* Handle the .err pseudo-op. */
1637 int ignore ATTRIBUTE_UNUSED
;
1639 as_bad (_(".err encountered"));
1640 demand_empty_rest_of_line ();
1643 /* Handle the MRI fail pseudo-op. */
1647 int ignore ATTRIBUTE_UNUSED
;
1654 stop
= mri_comment_field (&stopc
);
1656 temp
= get_absolute_expression ();
1658 as_warn (_(".fail %ld encountered"), (long) temp
);
1660 as_bad (_(".fail %ld encountered"), (long) temp
);
1662 demand_empty_rest_of_line ();
1665 mri_comment_end (stop
, stopc
);
1670 int ignore ATTRIBUTE_UNUSED
;
1672 expressionS rep_exp
;
1674 register long fill
= 0;
1677 #ifdef md_flush_pending_output
1678 md_flush_pending_output ();
1681 get_known_segmented_expression (&rep_exp
);
1682 if (*input_line_pointer
== ',')
1684 input_line_pointer
++;
1685 size
= get_absolute_expression ();
1686 if (*input_line_pointer
== ',')
1688 input_line_pointer
++;
1689 fill
= get_absolute_expression ();
1693 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1694 #define BSD_FILL_SIZE_CROCK_8 (8)
1695 if (size
> BSD_FILL_SIZE_CROCK_8
)
1697 as_warn (_(".fill size clamped to %d."), BSD_FILL_SIZE_CROCK_8
);
1698 size
= BSD_FILL_SIZE_CROCK_8
;
1702 as_warn (_("Size negative: .fill ignored."));
1705 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1707 if (rep_exp
.X_add_number
< 0)
1708 as_warn (_("Repeat < 0, .fill ignored"));
1712 if (size
&& !need_pass_2
)
1714 if (rep_exp
.X_op
== O_constant
)
1716 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1717 (relax_substateT
) 0, (symbolS
*) 0,
1718 (offsetT
) rep_exp
.X_add_number
,
1723 /* We don't have a constant repeat count, so we can't use
1724 rs_fill. We can get the same results out of rs_space,
1725 but its argument is in bytes, so we must multiply the
1726 repeat count by size. */
1729 rep_sym
= make_expr_symbol (&rep_exp
);
1732 expressionS size_exp
;
1733 size_exp
.X_op
= O_constant
;
1734 size_exp
.X_add_number
= size
;
1736 rep_exp
.X_op
= O_multiply
;
1737 rep_exp
.X_add_symbol
= rep_sym
;
1738 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1739 rep_exp
.X_add_number
= 0;
1740 rep_sym
= make_expr_symbol (&rep_exp
);
1743 p
= frag_var (rs_space
, (int) size
, (int) size
,
1744 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1746 memset (p
, 0, (unsigned int) size
);
1747 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1748 * flavoured AS. The following bizzare behaviour is to be
1749 * compatible with above. I guess they tried to take up to 8
1750 * bytes from a 4-byte expression and they forgot to sign
1751 * extend. Un*x Sux. */
1752 #define BSD_FILL_SIZE_CROCK_4 (4)
1753 md_number_to_chars (p
, (valueT
) fill
,
1754 (size
> BSD_FILL_SIZE_CROCK_4
1755 ? BSD_FILL_SIZE_CROCK_4
1757 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1758 * but emits no error message because it seems a legal thing to do.
1759 * It is a degenerate case of .fill but could be emitted by a compiler.
1762 demand_empty_rest_of_line ();
1767 int ignore ATTRIBUTE_UNUSED
;
1776 stop
= mri_comment_field (&stopc
);
1780 name
= input_line_pointer
;
1781 c
= get_symbol_end ();
1782 symbolP
= symbol_find_or_make (name
);
1783 S_SET_EXTERNAL (symbolP
);
1785 *input_line_pointer
= c
;
1787 c
= *input_line_pointer
;
1790 input_line_pointer
++;
1792 if (*input_line_pointer
== '\n')
1798 demand_empty_rest_of_line ();
1801 mri_comment_end (stop
, stopc
);
1804 /* Handle the MRI IRP and IRPC pseudo-ops. */
1816 as_where (&file
, &line
);
1819 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1820 sb_add_char (&s
, *input_line_pointer
++);
1824 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1826 as_bad_where (file
, line
, "%s", err
);
1830 input_scrub_include_sb (&out
, input_line_pointer
);
1832 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1835 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1836 the section to only be linked once. However, this is not supported
1837 by most object file formats. This takes an optional argument,
1838 which is what to do about duplicates. */
1842 int ignore ATTRIBUTE_UNUSED
;
1844 enum linkonce_type type
;
1848 type
= LINKONCE_DISCARD
;
1850 if (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1855 s
= input_line_pointer
;
1856 c
= get_symbol_end ();
1857 if (strcasecmp (s
, "discard") == 0)
1858 type
= LINKONCE_DISCARD
;
1859 else if (strcasecmp (s
, "one_only") == 0)
1860 type
= LINKONCE_ONE_ONLY
;
1861 else if (strcasecmp (s
, "same_size") == 0)
1862 type
= LINKONCE_SAME_SIZE
;
1863 else if (strcasecmp (s
, "same_contents") == 0)
1864 type
= LINKONCE_SAME_CONTENTS
;
1866 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1868 *input_line_pointer
= c
;
1871 #ifdef obj_handle_link_once
1872 obj_handle_link_once (type
);
1873 #else /* ! defined (obj_handle_link_once) */
1874 #ifdef BFD_ASSEMBLER
1878 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1879 as_warn (_(".linkonce is not supported for this object file format"));
1881 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1882 flags
|= SEC_LINK_ONCE
;
1887 case LINKONCE_DISCARD
:
1888 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1890 case LINKONCE_ONE_ONLY
:
1891 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1893 case LINKONCE_SAME_SIZE
:
1894 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1896 case LINKONCE_SAME_CONTENTS
:
1897 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1900 if (! bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1901 as_bad (_("bfd_set_section_flags: %s"),
1902 bfd_errmsg (bfd_get_error ()));
1904 #else /* ! defined (BFD_ASSEMBLER) */
1905 as_warn (_(".linkonce is not supported for this object file format"));
1906 #endif /* ! defined (BFD_ASSEMBLER) */
1907 #endif /* ! defined (obj_handle_link_once) */
1909 demand_empty_rest_of_line ();
1913 s_lcomm_internal (needs_align
, bytes_p
)
1914 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1915 (alignment); 0 if it was an ".lcomm" (2 args only) */
1917 /* 1 if the alignment value should be interpreted as the byte boundary,
1918 rather than the power of 2. */
1921 register char *name
;
1925 register symbolS
*symbolP
;
1926 segT current_seg
= now_seg
;
1927 subsegT current_subseg
= now_subseg
;
1928 const int max_alignment
= 15;
1930 segT bss_seg
= bss_section
;
1932 name
= input_line_pointer
;
1933 c
= get_symbol_end ();
1934 p
= input_line_pointer
;
1938 /* Accept an optional comma after the name. The comma used to be
1939 required, but Irix 5 cc does not generate it. */
1940 if (*input_line_pointer
== ',')
1942 ++input_line_pointer
;
1946 if (*input_line_pointer
== '\n')
1948 as_bad (_("Missing size expression"));
1952 if ((temp
= get_absolute_expression ()) < 0)
1954 as_warn (_("BSS length (%d.) <0! Ignored."), temp
);
1955 ignore_rest_of_line ();
1959 #if defined (TC_MIPS) || defined (TC_ALPHA)
1960 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1961 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1963 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1964 if (temp
<= bfd_get_gp_size (stdoutput
))
1966 bss_seg
= subseg_new (".sbss", 1);
1967 seg_info (bss_seg
)->bss
= 1;
1968 #ifdef BFD_ASSEMBLER
1969 if (! bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1970 as_warn (_("error setting flags for \".sbss\": %s"),
1971 bfd_errmsg (bfd_get_error ()));
1978 /* FIXME. This needs to be machine independent. */
1989 /* FIXME: This needs to be done in a more general fashion. */
1993 record_alignment(bss_seg
, align
);
2000 if (*input_line_pointer
!= ',')
2002 as_bad (_("Expected comma after size"));
2003 ignore_rest_of_line ();
2006 input_line_pointer
++;
2008 if (*input_line_pointer
== '\n')
2010 as_bad (_("Missing alignment"));
2013 align
= get_absolute_expression ();
2016 /* Convert to a power of 2. */
2021 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2024 as_bad (_("Alignment not a power of 2"));
2028 if (align
> max_alignment
)
2030 align
= max_alignment
;
2031 as_warn (_("Alignment too large: %d. assumed."), align
);
2036 as_warn (_("Alignment negative. 0 assumed."));
2038 record_alignment (bss_seg
, align
);
2039 } /* if needs align */
2042 /* Assume some objects may require alignment on some systems. */
2043 #if defined (TC_ALPHA) && ! defined (VMS)
2046 align
= ffs (temp
) - 1;
2047 if (temp
% (1 << align
))
2054 symbolP
= symbol_find_or_make (name
);
2058 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2059 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2060 #ifdef BFD_ASSEMBLER
2061 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2062 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2064 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2067 (S_GET_SEGMENT (symbolP
) == bss_seg
2068 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2072 subseg_set (bss_seg
, 1);
2075 frag_align (align
, 0, 0);
2076 /* detach from old frag */
2077 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2078 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2080 symbol_set_frag (symbolP
, frag_now
);
2081 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
2082 (offsetT
) temp
, (char *) 0);
2085 S_SET_SEGMENT (symbolP
, bss_seg
);
2088 /* The symbol may already have been created with a preceding
2089 ".globl" directive -- be careful not to step on storage class
2090 in that case. Otherwise, set it to static. */
2091 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2093 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2095 #endif /* OBJ_COFF */
2098 S_SET_SIZE (symbolP
, temp
);
2102 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
2103 S_GET_NAME (symbolP
));
2105 subseg_set (current_seg
, current_subseg
);
2107 demand_empty_rest_of_line ();
2108 } /* s_lcomm_internal() */
2111 s_lcomm (needs_align
)
2114 s_lcomm_internal (needs_align
, 0);
2117 void s_lcomm_bytes (needs_align
)
2120 s_lcomm_internal (needs_align
, 1);
2125 int ignore ATTRIBUTE_UNUSED
;
2127 register char *name
;
2131 register symbolS
*symbolP
;
2133 /* we permit ANY defined expression: BSD4.2 demands constants */
2134 name
= input_line_pointer
;
2135 c
= get_symbol_end ();
2136 p
= input_line_pointer
;
2139 if (*input_line_pointer
!= ',')
2142 as_bad (_("Expected comma after name \"%s\""), name
);
2144 ignore_rest_of_line ();
2147 input_line_pointer
++;
2149 if (exp
.X_op
!= O_constant
2150 && exp
.X_op
!= O_register
)
2152 as_bad (_("bad expression"));
2153 ignore_rest_of_line ();
2157 symbolP
= symbol_find_or_make (name
);
2159 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2160 symbolP->sy_desc == 0) out of this test because coff doesn't have
2161 those fields, and I can't see when they'd ever be tripped. I
2162 don't think I understand why they were here so I may have
2163 introduced a bug. As recently as 1.37 didn't have this test
2164 anyway. xoxorich. */
2166 if (S_GET_SEGMENT (symbolP
) == undefined_section
2167 && S_GET_VALUE (symbolP
) == 0)
2169 /* The name might be an undefined .global symbol; be sure to
2170 keep the "external" bit. */
2171 S_SET_SEGMENT (symbolP
,
2172 (exp
.X_op
== O_constant
2175 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2179 as_bad (_("Symbol %s already defined"), name
);
2182 demand_empty_rest_of_line ();
2185 /* Read a line into an sb. */
2191 char quote1
, quote2
, inquote
;
2193 if (input_line_pointer
[-1] == '\n')
2194 bump_line_counters ();
2196 if (input_line_pointer
>= buffer_limit
)
2198 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2199 if (buffer_limit
== 0)
2203 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2204 code needs to be changed. */
2205 if (! flag_m68k_mri
)
2213 #ifdef LEX_IS_STRINGQUOTE
2218 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
2219 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2221 if (inquote
== *input_line_pointer
)
2223 else if (inquote
== '\0')
2225 if (*input_line_pointer
== quote1
)
2227 else if (*input_line_pointer
== quote2
)
2230 sb_add_char (line
, *input_line_pointer
++);
2232 while (input_line_pointer
< buffer_limit
2233 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2235 if (input_line_pointer
[-1] == '\n')
2236 bump_line_counters ();
2237 ++input_line_pointer
;
2242 /* Define a macro. This is an interface to macro.c, which is shared
2243 between gas and gasp. */
2247 int ignore ATTRIBUTE_UNUSED
;
2256 as_where (&file
, &line
);
2259 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
2260 sb_add_char (&s
, *input_line_pointer
++);
2263 if (line_label
!= NULL
)
2264 sb_add_string (&label
, S_GET_NAME (line_label
));
2266 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2268 as_bad_where (file
, line
, "%s", err
);
2271 if (line_label
!= NULL
)
2273 S_SET_SEGMENT (line_label
, undefined_section
);
2274 S_SET_VALUE (line_label
, 0);
2275 symbol_set_frag (line_label
, &zero_address_frag
);
2278 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2279 && hash_find (po_hash
, name
) != NULL
)
2282 && hash_find (po_hash
, name
+ 1) != NULL
))
2283 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2290 /* Handle the .mexit pseudo-op, which immediately exits a macro
2295 int ignore ATTRIBUTE_UNUSED
;
2297 cond_exit_macro (macro_nest
);
2298 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2301 /* Switch in and out of MRI mode. */
2305 int ignore ATTRIBUTE_UNUSED
;
2309 on
= get_absolute_expression ();
2310 old_flag
= flag_mri
;
2328 /* Operator precedence changes in m68k MRI mode, so we need to
2329 update the operator rankings. */
2330 expr_set_precedence ();
2332 #ifdef MRI_MODE_CHANGE
2334 MRI_MODE_CHANGE (on
);
2337 demand_empty_rest_of_line ();
2340 /* Handle changing the location counter. */
2343 do_org (segment
, exp
, fill
)
2348 if (segment
!= now_seg
&& segment
!= absolute_section
)
2349 as_bad (_("invalid segment \"%s\"; segment \"%s\" assumed"),
2350 segment_name (segment
), segment_name (now_seg
));
2352 if (now_seg
== absolute_section
)
2355 as_warn (_("ignoring fill value in absolute section"));
2356 if (exp
->X_op
!= O_constant
)
2358 as_bad (_("only constant offsets supported in absolute section"));
2359 exp
->X_add_number
= 0;
2361 abs_section_offset
= exp
->X_add_number
;
2367 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
->X_add_symbol
,
2368 exp
->X_add_number
* OCTETS_PER_BYTE
, (char *) NULL
);
2375 int ignore ATTRIBUTE_UNUSED
;
2377 register segT segment
;
2379 register long temp_fill
;
2381 #ifdef md_flush_pending_output
2382 md_flush_pending_output ();
2385 /* The m68k MRI assembler has a different meaning for .org. It
2386 means to create an absolute section at a given address. We can't
2387 support that--use a linker script instead. */
2390 as_bad (_("MRI style ORG pseudo-op not supported"));
2391 ignore_rest_of_line ();
2395 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2396 thing as a sub-segment-relative origin. Any absolute origin is
2397 given a warning, then assumed to be segment-relative. Any
2398 segmented origin expression ("foo+42") had better be in the right
2399 segment or the .org is ignored.
2401 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2402 we never know sub-segment sizes when we are reading code. BSD
2403 will crash trying to emit negative numbers of filler bytes in
2404 certain .orgs. We don't crash, but see as-write for that code.
2406 Don't make frag if need_pass_2==1. */
2407 segment
= get_known_segmented_expression (&exp
);
2408 if (*input_line_pointer
== ',')
2410 input_line_pointer
++;
2411 temp_fill
= get_absolute_expression ();
2417 do_org (segment
, &exp
, temp_fill
);
2419 demand_empty_rest_of_line ();
2422 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2423 called by the obj-format routine which handles section changing
2424 when in MRI mode. It will create a new section, and return it. It
2425 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2426 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2427 flags will be set in the section. */
2431 char *type ATTRIBUTE_UNUSED
;
2441 name
= input_line_pointer
;
2442 if (! isdigit ((unsigned char) *name
))
2443 c
= get_symbol_end ();
2448 ++input_line_pointer
;
2450 while (isdigit ((unsigned char) *input_line_pointer
));
2451 c
= *input_line_pointer
;
2452 *input_line_pointer
= '\0';
2455 name
= xstrdup (name
);
2457 *input_line_pointer
= c
;
2459 seg
= subseg_new (name
, 0);
2461 if (*input_line_pointer
== ',')
2465 ++input_line_pointer
;
2466 align
= get_absolute_expression ();
2467 record_alignment (seg
, align
);
2471 if (*input_line_pointer
== ',')
2473 c
= *++input_line_pointer
;
2474 c
= toupper ((unsigned char) c
);
2475 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2478 as_bad (_("unrecognized section type"));
2479 ++input_line_pointer
;
2481 #ifdef BFD_ASSEMBLER
2485 flags
= SEC_NO_FLAGS
;
2487 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2488 else if (*type
== 'D' || *type
== 'M')
2489 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2490 else if (*type
== 'R')
2491 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2492 if (flags
!= SEC_NO_FLAGS
)
2494 if (! bfd_set_section_flags (stdoutput
, seg
, flags
))
2495 as_warn (_("error setting flags for \"%s\": %s"),
2496 bfd_section_name (stdoutput
, seg
),
2497 bfd_errmsg (bfd_get_error ()));
2503 /* Ignore the HP type. */
2504 if (*input_line_pointer
== ',')
2505 input_line_pointer
+= 2;
2507 demand_empty_rest_of_line ();
2509 #else /* ! TC_M68K */
2518 name
= input_line_pointer
;
2519 c
= get_symbol_end ();
2521 name
= xstrdup (name
);
2523 *input_line_pointer
= c
;
2525 seg
= subseg_new (name
, 0);
2527 if (*input_line_pointer
!= ',')
2533 ++input_line_pointer
;
2535 sectype
= input_line_pointer
;
2536 c
= get_symbol_end ();
2537 if (*sectype
== '\0')
2539 else if (strcasecmp (sectype
, "text") == 0)
2541 else if (strcasecmp (sectype
, "data") == 0)
2543 else if (strcasecmp (sectype
, "romdata") == 0)
2546 as_warn (_("unrecognized section type `%s'"), sectype
);
2547 *input_line_pointer
= c
;
2550 if (*input_line_pointer
== ',')
2554 ++input_line_pointer
;
2556 seccmd
= input_line_pointer
;
2557 c
= get_symbol_end ();
2558 if (strcasecmp (seccmd
, "absolute") == 0)
2560 as_bad (_("absolute sections are not supported"));
2561 *input_line_pointer
= c
;
2562 ignore_rest_of_line ();
2565 else if (strcasecmp (seccmd
, "align") == 0)
2569 *input_line_pointer
= c
;
2570 align
= get_absolute_expression ();
2571 record_alignment (seg
, align
);
2575 as_warn (_("unrecognized section command `%s'"), seccmd
);
2576 *input_line_pointer
= c
;
2580 demand_empty_rest_of_line ();
2582 #else /* ! TC_I960 */
2583 /* The MRI assembler seems to use different forms of .sect for
2584 different targets. */
2585 as_bad ("MRI mode not supported for this target");
2586 ignore_rest_of_line ();
2587 #endif /* ! TC_I960 */
2588 #endif /* ! TC_M68K */
2591 /* Handle the .print pseudo-op. */
2595 int ignore ATTRIBUTE_UNUSED
;
2600 s
= demand_copy_C_string (&len
);
2602 demand_empty_rest_of_line ();
2605 /* Handle the .purgem pseudo-op. */
2609 int ignore ATTRIBUTE_UNUSED
;
2611 if (is_it_end_of_statement ())
2613 demand_empty_rest_of_line ();
2623 name
= input_line_pointer
;
2624 c
= get_symbol_end ();
2625 delete_macro (name
);
2626 *input_line_pointer
= c
;
2629 while (*input_line_pointer
++ == ',');
2631 --input_line_pointer
;
2632 demand_empty_rest_of_line ();
2635 /* Handle the .rept pseudo-op. */
2639 int ignore ATTRIBUTE_UNUSED
;
2643 count
= get_absolute_expression ();
2645 do_repeat(count
, "REPT", "ENDR");
2648 /* This function provides a generic repeat block implementation. It allows
2649 different directives to be used as the start/end keys. */
2652 do_repeat (count
, start
, end
)
2661 if (! buffer_and_nest (start
, end
, &one
, get_line_sb
))
2663 as_bad (_("%s without %s"), start
, end
);
2669 sb_add_sb (&many
, &one
);
2673 input_scrub_include_sb (&many
, input_line_pointer
);
2675 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2678 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2679 input buffers to skip. Assumes that conditionals preceding the loop end
2680 are properly nested.
2682 This function makes it easier to implement a premature "break" out of the
2683 loop. The EXTRA arg accounts for other buffers we might have inserted,
2684 such as line substitutions. */
2690 cond_exit_macro (macro_nest
);
2691 while (extra
-- >= 0)
2692 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2695 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2696 this is .equiv, and it is an error if the symbol is already
2703 register char *name
;
2704 register char delim
;
2705 register char *end_name
;
2706 register symbolS
*symbolP
;
2709 * Especial apologies for the random logic:
2710 * this just grew, and could be parsed much more simply!
2713 name
= input_line_pointer
;
2714 delim
= get_symbol_end ();
2715 end_name
= input_line_pointer
;
2719 if (*input_line_pointer
!= ',')
2722 as_bad (_("Expected comma after name \"%s\""), name
);
2724 ignore_rest_of_line ();
2728 input_line_pointer
++;
2731 if (name
[0] == '.' && name
[1] == '\0')
2733 /* Turn '. = mumble' into a .org mumble */
2734 register segT segment
;
2737 segment
= get_known_segmented_expression (&exp
);
2740 do_org (segment
, &exp
, 0);
2746 if ((symbolP
= symbol_find (name
)) == NULL
2747 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2750 /* When doing symbol listings, play games with dummy fragments living
2751 outside the normal fragment chain to record the file and line info
2753 if (listing
& LISTING_SYMBOLS
)
2755 extern struct list_info_struct
*listing_tail
;
2756 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof(fragS
));
2757 memset (dummy_frag
, 0, sizeof(fragS
));
2758 dummy_frag
->fr_type
= rs_fill
;
2759 dummy_frag
->line
= listing_tail
;
2760 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2761 dummy_frag
->fr_symbol
= symbolP
;
2765 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2768 /* "set" symbols are local unless otherwise specified. */
2769 SF_SET_LOCAL (symbolP
);
2770 #endif /* OBJ_COFF */
2772 } /* make a new symbol */
2774 symbol_table_insert (symbolP
);
2779 && S_IS_DEFINED (symbolP
)
2780 && S_GET_SEGMENT (symbolP
) != reg_section
)
2781 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
2783 pseudo_set (symbolP
);
2784 demand_empty_rest_of_line ();
2798 #ifdef md_flush_pending_output
2799 md_flush_pending_output ();
2803 stop
= mri_comment_field (&stopc
);
2805 /* In m68k MRI mode, we need to align to a word boundary, unless
2807 if (flag_m68k_mri
&& mult
> 1)
2809 if (now_seg
== absolute_section
)
2811 abs_section_offset
+= abs_section_offset
& 1;
2812 if (line_label
!= NULL
)
2813 S_SET_VALUE (line_label
, abs_section_offset
);
2815 else if (mri_common_symbol
!= NULL
)
2819 val
= S_GET_VALUE (mri_common_symbol
);
2822 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2823 if (line_label
!= NULL
)
2825 expressionS
*symexp
;
2827 symexp
= symbol_get_value_expression (line_label
);
2828 know (symexp
->X_op
== O_symbol
);
2829 know (symexp
->X_add_symbol
== mri_common_symbol
);
2830 symexp
->X_add_number
+= 1;
2836 do_align (1, (char *) NULL
, 0, 0);
2837 if (line_label
!= NULL
)
2839 symbol_set_frag (line_label
, frag_now
);
2840 S_SET_VALUE (line_label
, frag_now_fix ());
2850 if (*input_line_pointer
== ',')
2852 ++input_line_pointer
;
2857 val
.X_op
= O_constant
;
2858 val
.X_add_number
= 0;
2861 if (val
.X_op
!= O_constant
2862 || val
.X_add_number
< - 0x80
2863 || val
.X_add_number
> 0xff
2864 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2866 if (exp
.X_op
!= O_constant
)
2867 as_bad (_("Unsupported variable size or fill value"));
2874 bytes
= mult
* exp
.X_add_number
;
2875 for (i
= 0; i
< exp
.X_add_number
; i
++)
2876 emit_expr (&val
, mult
);
2881 if (exp
.X_op
== O_constant
)
2885 repeat
= exp
.X_add_number
;
2892 as_warn (_(".space repeat count is zero, ignored"));
2893 else if (repeat
< 0)
2894 as_warn (_(".space repeat count is negative, ignored"));
2898 /* If we are in the absolute section, just bump the offset. */
2899 if (now_seg
== absolute_section
)
2901 abs_section_offset
+= repeat
;
2905 /* If we are secretly in an MRI common section, then
2906 creating space just increases the size of the common
2908 if (mri_common_symbol
!= NULL
)
2910 S_SET_VALUE (mri_common_symbol
,
2911 S_GET_VALUE (mri_common_symbol
) + repeat
);
2916 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2917 (offsetT
) repeat
, (char *) 0);
2921 if (now_seg
== absolute_section
)
2923 as_bad (_("space allocation too complex in absolute section"));
2924 subseg_set (text_section
, 0);
2926 if (mri_common_symbol
!= NULL
)
2928 as_bad (_("space allocation too complex in common section"));
2929 mri_common_symbol
= NULL
;
2932 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2933 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2937 *p
= val
.X_add_number
;
2942 /* In MRI mode, after an odd number of bytes, we must align to an
2943 even word boundary, unless the next instruction is a dc.b, ds.b
2945 if (flag_mri
&& (bytes
& 1) != 0)
2946 mri_pending_align
= 1;
2948 demand_empty_rest_of_line ();
2951 mri_comment_end (stop
, stopc
);
2954 /* This is like s_space, but the value is a floating point number with
2955 the given precision. This is for the MRI dcb.s pseudo-op and
2959 s_float_space (float_type
)
2964 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2969 stop
= mri_comment_field (&stopc
);
2971 count
= get_absolute_expression ();
2974 if (*input_line_pointer
!= ',')
2976 as_bad (_("missing value"));
2977 ignore_rest_of_line ();
2979 mri_comment_end (stop
, stopc
);
2983 ++input_line_pointer
;
2987 /* Skip any 0{letter} that may be present. Don't even check if the
2988 * letter is legal. */
2989 if (input_line_pointer
[0] == '0'
2990 && isalpha ((unsigned char) input_line_pointer
[1]))
2991 input_line_pointer
+= 2;
2993 /* Accept :xxxx, where the x's are hex digits, for a floating point
2994 with the exact digits specified. */
2995 if (input_line_pointer
[0] == ':')
2997 flen
= hex_float (float_type
, temp
);
3000 ignore_rest_of_line ();
3002 mri_comment_end (stop
, stopc
);
3010 err
= md_atof (float_type
, temp
, &flen
);
3011 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3015 as_bad (_("Bad floating literal: %s"), err
);
3016 ignore_rest_of_line ();
3018 mri_comment_end (stop
, stopc
);
3023 while (--count
>= 0)
3027 p
= frag_more (flen
);
3028 memcpy (p
, temp
, (unsigned int) flen
);
3031 demand_empty_rest_of_line ();
3034 mri_comment_end (stop
, stopc
);
3037 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3041 int ignore ATTRIBUTE_UNUSED
;
3047 stop
= mri_comment_field (&stopc
);
3048 abs_section_offset
= get_absolute_expression ();
3049 subseg_set (absolute_section
, 0);
3050 demand_empty_rest_of_line ();
3052 mri_comment_end (stop
, stopc
);
3057 int ignore ATTRIBUTE_UNUSED
;
3061 temp
= get_absolute_expression ();
3062 subseg_set (text_section
, (subsegT
) temp
);
3063 demand_empty_rest_of_line ();
3065 const_flag
&= ~IN_DEFAULT_SECTION
;
3071 demand_empty_rest_of_line ()
3074 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3076 input_line_pointer
++;
3080 ignore_rest_of_line ();
3082 /* Return having already swallowed end-of-line. */
3083 } /* Return pointing just after end-of-line. */
3086 ignore_rest_of_line () /* For suspect lines: gives warning. */
3088 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3090 if (isprint ((unsigned char) *input_line_pointer
))
3091 as_bad (_("Rest of line ignored. First ignored character is `%c'."),
3092 *input_line_pointer
);
3094 as_bad (_("Rest of line ignored. First ignored character valued 0x%x."),
3095 *input_line_pointer
);
3096 while (input_line_pointer
< buffer_limit
3097 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3099 input_line_pointer
++;
3102 input_line_pointer
++; /* Return pointing just after end-of-line. */
3103 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3107 discard_rest_of_line ()
3109 while (input_line_pointer
< buffer_limit
3110 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3112 input_line_pointer
++;
3114 input_line_pointer
++; /* Return pointing just after end-of-line. */
3115 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3121 * In: Pointer to a symbol.
3122 * Input_line_pointer->expression.
3124 * Out: Input_line_pointer->just after any whitespace after expression.
3125 * Tried to set symbol to value of expression.
3126 * Will change symbols type, value, and frag;
3129 pseudo_set (symbolP
)
3133 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3135 #endif /* OBJ_AOUT or OBJ_BOUT */
3137 know (symbolP
); /* NULL pointer is logic error. */
3138 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3139 ext
= S_IS_EXTERNAL (symbolP
);
3140 #endif /* OBJ_AOUT or OBJ_BOUT */
3142 (void) expression (&exp
);
3144 if (exp
.X_op
== O_illegal
)
3145 as_bad (_("illegal expression; zero assumed"));
3146 else if (exp
.X_op
== O_absent
)
3147 as_bad (_("missing expression; zero assumed"));
3148 else if (exp
.X_op
== O_big
)
3150 if (exp
.X_add_number
> 0)
3151 as_bad (_("bignum invalid; zero assumed"));
3153 as_bad (_("floating point number invalid; zero assumed"));
3155 else if (exp
.X_op
== O_subtract
3156 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3157 == S_GET_SEGMENT (exp
.X_op_symbol
))
3158 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3159 && (symbol_get_frag (exp
.X_add_symbol
)
3160 == symbol_get_frag (exp
.X_op_symbol
)))
3162 exp
.X_op
= O_constant
;
3163 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3164 - S_GET_VALUE (exp
.X_op_symbol
));
3172 exp
.X_add_number
= 0;
3175 S_SET_SEGMENT (symbolP
, absolute_section
);
3176 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3178 S_SET_EXTERNAL (symbolP
);
3180 S_CLEAR_EXTERNAL (symbolP
);
3181 #endif /* OBJ_AOUT or OBJ_BOUT */
3182 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3183 if (exp
.X_op
!= O_constant
)
3184 symbol_set_frag (symbolP
, &zero_address_frag
);
3188 S_SET_SEGMENT (symbolP
, reg_section
);
3189 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3190 symbol_set_frag (symbolP
, &zero_address_frag
);
3194 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3195 || exp
.X_add_number
!= 0)
3196 symbol_set_value_expression (symbolP
, &exp
);
3197 else if (symbol_section_p (symbolP
))
3198 as_bad ("invalid attempt to set value of section symbol");
3201 symbolS
*s
= exp
.X_add_symbol
;
3203 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3204 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3206 S_SET_EXTERNAL (symbolP
);
3208 S_CLEAR_EXTERNAL (symbolP
);
3209 #endif /* OBJ_AOUT or OBJ_BOUT */
3210 S_SET_VALUE (symbolP
,
3211 exp
.X_add_number
+ S_GET_VALUE (s
));
3212 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3213 copy_symbol_attributes (symbolP
, s
);
3218 /* The value is some complex expression.
3219 FIXME: Should we set the segment to anything? */
3220 symbol_set_value_expression (symbolP
, &exp
);
3228 * CONStruct more frag of .bytes, or .words etc.
3229 * Should need_pass_2 be 1 then emit no frag(s).
3230 * This understands EXPRESSIONS.
3234 * This has a split personality. We use expression() to read the
3235 * value. We can detect if the value won't fit in a byte or word.
3236 * But we can't detect if expression() discarded significant digits
3237 * in the case of a long. Not worth the crocks required to fix it.
3240 /* Select a parser for cons expressions. */
3242 /* Some targets need to parse the expression in various fancy ways.
3243 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3244 (for example, the HPPA does this). Otherwise, you can define
3245 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3246 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3247 are defined, which is the normal case, then only simple expressions
3252 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3255 #ifndef TC_PARSE_CONS_EXPRESSION
3256 #ifdef BITFIELD_CONS_EXPRESSIONS
3257 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3259 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3261 #ifdef REPEAT_CONS_EXPRESSIONS
3262 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3264 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3267 /* If we haven't gotten one yet, just call expression. */
3268 #ifndef TC_PARSE_CONS_EXPRESSION
3269 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3273 /* worker to do .byte etc statements */
3274 /* clobbers input_line_pointer, checks */
3277 cons_worker (nbytes
, rva
)
3278 register int nbytes
; /* 1=.byte, 2=.word, 4=.long */
3286 #ifdef md_flush_pending_output
3287 md_flush_pending_output ();
3291 stop
= mri_comment_field (&stopc
);
3293 if (is_it_end_of_statement ())
3295 demand_empty_rest_of_line ();
3297 mri_comment_end (stop
, stopc
);
3301 #ifdef md_cons_align
3302 md_cons_align (nbytes
);
3310 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3313 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3317 if (exp
.X_op
== O_symbol
)
3318 exp
.X_op
= O_symbol_rva
;
3320 as_fatal (_("rva without symbol"));
3322 emit_expr (&exp
, (unsigned int) nbytes
);
3325 while (*input_line_pointer
++ == ',');
3327 /* In MRI mode, after an odd number of bytes, we must align to an
3328 even word boundary, unless the next instruction is a dc.b, ds.b
3330 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3331 mri_pending_align
= 1;
3333 input_line_pointer
--; /* Put terminator back into stream. */
3335 demand_empty_rest_of_line ();
3338 mri_comment_end (stop
, stopc
);
3346 cons_worker (size
, 0);
3353 cons_worker (size
, 1);
3356 /* Put the contents of expression EXP into the object file using
3357 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3360 emit_expr (exp
, nbytes
)
3362 unsigned int nbytes
;
3366 valueT extra_digit
= 0;
3368 /* Don't do anything if we are going to make another pass. */
3374 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3375 appear as a four byte positive constant in the .line section,
3376 followed by a 2 byte 0xffff. Look for that case here. */
3378 static int dwarf_line
= -1;
3380 if (strcmp (segment_name (now_seg
), ".line") != 0)
3382 else if (dwarf_line
>= 0
3384 && exp
->X_op
== O_constant
3385 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3386 listing_source_line ((unsigned int) dwarf_line
);
3387 else if (nbytes
== 4
3388 && exp
->X_op
== O_constant
3389 && exp
->X_add_number
>= 0)
3390 dwarf_line
= exp
->X_add_number
;
3395 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3396 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3397 AT_sibling (0x12) followed by a four byte address of the sibling
3398 followed by a 2 byte AT_name (0x38) followed by the name of the
3399 file. We look for that case here. */
3401 static int dwarf_file
= 0;
3403 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3405 else if (dwarf_file
== 0
3407 && exp
->X_op
== O_constant
3408 && exp
->X_add_number
== 0x11)
3410 else if (dwarf_file
== 1
3412 && exp
->X_op
== O_constant
3413 && exp
->X_add_number
== 0x12)
3415 else if (dwarf_file
== 2
3418 else if (dwarf_file
== 3
3420 && exp
->X_op
== O_constant
3421 && exp
->X_add_number
== 0x38)
3426 /* The variable dwarf_file_string tells stringer that the string
3427 may be the name of the source file. */
3428 if (dwarf_file
== 4)
3429 dwarf_file_string
= 1;
3431 dwarf_file_string
= 0;
3436 if (check_eh_frame (exp
, &nbytes
))
3441 /* Allow `.word 0' in the absolute section. */
3442 if (now_seg
== absolute_section
)
3444 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3445 as_bad (_("attempt to store value in absolute section"));
3446 abs_section_offset
+= nbytes
;
3450 /* Handle a negative bignum. */
3452 && exp
->X_add_number
== 0
3453 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3454 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3457 unsigned long carry
;
3459 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3461 /* Negate the bignum: one's complement each digit and add 1. */
3463 for (i
= 0; i
< exp
->X_add_number
; i
++)
3467 next
= (((~ (generic_bignum
[i
] & LITTLENUM_MASK
))
3470 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3471 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3474 /* We can ignore any carry out, because it will be handled by
3475 extra_digit if it is needed. */
3477 extra_digit
= (valueT
) -1;
3481 if (op
== O_absent
|| op
== O_illegal
)
3483 as_warn (_("zero assumed for missing expression"));
3484 exp
->X_add_number
= 0;
3487 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3489 as_bad (_("floating point number invalid; zero assumed"));
3490 exp
->X_add_number
= 0;
3493 else if (op
== O_register
)
3495 as_warn (_("register value used as expression"));
3499 p
= frag_more ((int) nbytes
);
3501 #ifndef WORKING_DOT_WORD
3502 /* If we have the difference of two symbols in a word, save it on
3503 the broken_words list. See the code in write.c. */
3504 if (op
== O_subtract
&& nbytes
== 2)
3506 struct broken_word
*x
;
3508 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3509 x
->next_broken_word
= broken_words
;
3512 x
->subseg
= now_subseg
;
3514 x
->word_goes_here
= p
;
3516 x
->add
= exp
->X_add_symbol
;
3517 x
->sub
= exp
->X_op_symbol
;
3518 x
->addnum
= exp
->X_add_number
;
3525 /* If we have an integer, but the number of bytes is too large to
3526 pass to md_number_to_chars, handle it as a bignum. */
3527 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3532 if (! exp
->X_unsigned
&& exp
->X_add_number
< 0)
3533 extra_digit
= (valueT
) -1;
3534 val
= (valueT
) exp
->X_add_number
;
3538 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3539 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3543 op
= exp
->X_op
= O_big
;
3544 exp
->X_add_number
= gencnt
;
3547 if (op
== O_constant
)
3549 register valueT get
;
3550 register valueT use
;
3551 register valueT mask
;
3553 register valueT unmask
;
3555 /* JF << of >= number of bits in the object is undefined. In
3556 particular SPARC (Sun 4) has problems */
3557 if (nbytes
>= sizeof (valueT
))
3560 if (nbytes
> sizeof (valueT
))
3563 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3567 /* Don't store these bits. */
3568 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3569 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3572 unmask
= ~mask
; /* Do store these bits. */
3575 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3576 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3579 get
= exp
->X_add_number
;
3581 if ((get
& mask
) != 0
3582 && ((get
& mask
) != mask
3583 || (get
& hibit
) == 0))
3584 { /* Leading bits contain both 0s & 1s. */
3585 as_warn (_("Value 0x%lx truncated to 0x%lx."),
3586 (unsigned long) get
, (unsigned long) use
);
3588 /* put bytes in right order. */
3589 md_number_to_chars (p
, use
, (int) nbytes
);
3591 else if (op
== O_big
)
3594 LITTLENUM_TYPE
*nums
;
3596 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3598 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3601 as_warn (_("Bignum truncated to %d bytes"), nbytes
);
3605 if (target_big_endian
)
3607 while (nbytes
> size
)
3609 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3610 nbytes
-= CHARS_PER_LITTLENUM
;
3611 p
+= CHARS_PER_LITTLENUM
;
3614 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3618 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3619 size
-= CHARS_PER_LITTLENUM
;
3620 p
+= CHARS_PER_LITTLENUM
;
3625 nums
= generic_bignum
;
3628 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3630 size
-= CHARS_PER_LITTLENUM
;
3631 p
+= CHARS_PER_LITTLENUM
;
3632 nbytes
-= CHARS_PER_LITTLENUM
;
3637 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3638 nbytes
-= CHARS_PER_LITTLENUM
;
3639 p
+= CHARS_PER_LITTLENUM
;
3645 memset (p
, 0, nbytes
);
3647 /* Now we need to generate a fixS to record the symbol value.
3648 This is easy for BFD. For other targets it can be more
3649 complex. For very complex cases (currently, the HPPA and
3650 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3651 want. For simpler cases, you can define TC_CONS_RELOC to be
3652 the name of the reloc code that should be stored in the fixS.
3653 If neither is defined, the code uses NO_RELOC if it is
3654 defined, and otherwise uses 0. */
3656 #ifdef BFD_ASSEMBLER
3657 #ifdef TC_CONS_FIX_NEW
3658 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3661 bfd_reloc_code_real_type r
;
3678 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3682 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3687 #ifdef TC_CONS_FIX_NEW
3688 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3690 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3691 it is defined, otherwise use NO_RELOC if it is defined,
3693 #ifndef TC_CONS_RELOC
3695 #define TC_CONS_RELOC NO_RELOC
3697 #define TC_CONS_RELOC 0
3700 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3702 #endif /* TC_CONS_FIX_NEW */
3703 #endif /* BFD_ASSEMBLER */
3707 #ifdef BITFIELD_CONS_EXPRESSIONS
3709 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3710 w:x,y:z, where w and y are bitwidths and x and y are values. They
3711 then pack them all together. We do a little better in that we allow
3712 them in words, longs, etc. and we'll pack them in target byte order
3715 The rules are: pack least significat bit first, if a field doesn't
3716 entirely fit, put it in the next unit. Overflowing the bitfield is
3717 explicitly *not* even a warning. The bitwidth should be considered
3720 To use this function the tc-XXX.h file should define
3721 BITFIELD_CONS_EXPRESSIONS. */
3724 parse_bitfield_cons (exp
, nbytes
)
3726 unsigned int nbytes
;
3728 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3729 char *hold
= input_line_pointer
;
3731 (void) expression (exp
);
3733 if (*input_line_pointer
== ':')
3739 unsigned long width
;
3741 if (*input_line_pointer
!= ':')
3743 input_line_pointer
= hold
;
3745 } /* next piece is not a bitfield */
3747 /* In the general case, we can't allow
3748 full expressions with symbol
3749 differences and such. The relocation
3750 entries for symbols not defined in this
3751 assembly would require arbitrary field
3752 widths, positions, and masks which most
3753 of our current object formats don't
3756 In the specific case where a symbol
3757 *is* defined in this assembly, we
3758 *could* build fixups and track it, but
3759 this could lead to confusion for the
3760 backends. I'm lazy. I'll take any
3761 SEG_ABSOLUTE. I think that means that
3762 you can use a previous .set or
3763 .equ type symbol. xoxorich. */
3765 if (exp
->X_op
== O_absent
)
3767 as_warn (_("using a bit field width of zero"));
3768 exp
->X_add_number
= 0;
3769 exp
->X_op
= O_constant
;
3770 } /* implied zero width bitfield */
3772 if (exp
->X_op
!= O_constant
)
3774 *input_line_pointer
= '\0';
3775 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3776 *input_line_pointer
= ':';
3777 demand_empty_rest_of_line ();
3781 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3783 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3784 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3785 width
= BITS_PER_CHAR
* nbytes
;
3788 if (width
> bits_available
)
3790 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3791 input_line_pointer
= hold
;
3792 exp
->X_add_number
= value
;
3796 hold
= ++input_line_pointer
; /* skip ':' */
3798 (void) expression (exp
);
3799 if (exp
->X_op
!= O_constant
)
3801 char cache
= *input_line_pointer
;
3803 *input_line_pointer
= '\0';
3804 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3805 *input_line_pointer
= cache
;
3806 demand_empty_rest_of_line ();
3810 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3811 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3813 if ((bits_available
-= width
) == 0
3814 || is_it_end_of_statement ()
3815 || *input_line_pointer
!= ',')
3818 } /* all the bitfields we're gonna get */
3820 hold
= ++input_line_pointer
;
3821 (void) expression (exp
);
3822 } /* forever loop */
3824 exp
->X_add_number
= value
;
3825 exp
->X_op
= O_constant
;
3826 exp
->X_unsigned
= 1;
3827 } /* if looks like a bitfield */
3828 } /* parse_bitfield_cons() */
3830 #endif /* BITFIELD_CONS_EXPRESSIONS */
3832 /* Handle an MRI style string expression. */
3836 parse_mri_cons (exp
, nbytes
)
3838 unsigned int nbytes
;
3840 if (*input_line_pointer
!= '\''
3841 && (input_line_pointer
[1] != '\''
3842 || (*input_line_pointer
!= 'A'
3843 && *input_line_pointer
!= 'E')))
3844 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3848 unsigned int result
= 0;
3850 /* An MRI style string. Cut into as many bytes as will fit into
3851 a nbyte chunk, left justify if necessary, and separate with
3852 commas so we can try again later. */
3853 if (*input_line_pointer
== 'A')
3854 ++input_line_pointer
;
3855 else if (*input_line_pointer
== 'E')
3857 as_bad (_("EBCDIC constants are not supported"));
3858 ++input_line_pointer
;
3861 input_line_pointer
++;
3862 for (scan
= 0; scan
< nbytes
; scan
++)
3864 if (*input_line_pointer
== '\'')
3866 if (input_line_pointer
[1] == '\'')
3868 input_line_pointer
++;
3873 result
= (result
<< 8) | (*input_line_pointer
++);
3877 while (scan
< nbytes
)
3882 /* Create correct expression */
3883 exp
->X_op
= O_constant
;
3884 exp
->X_add_number
= result
;
3885 /* Fake it so that we can read the next char too */
3886 if (input_line_pointer
[0] != '\'' ||
3887 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3889 input_line_pointer
-= 2;
3890 input_line_pointer
[0] = ',';
3891 input_line_pointer
[1] = '\'';
3894 input_line_pointer
++;
3897 #endif /* TC_M68K */
3899 #ifdef REPEAT_CONS_EXPRESSIONS
3901 /* Parse a repeat expression for cons. This is used by the MIPS
3902 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3903 object file COUNT times.
3905 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3908 parse_repeat_cons (exp
, nbytes
)
3910 unsigned int nbytes
;
3917 if (*input_line_pointer
!= ':')
3919 /* No repeat count. */
3923 ++input_line_pointer
;
3924 expression (&count
);
3925 if (count
.X_op
!= O_constant
3926 || count
.X_add_number
<= 0)
3928 as_warn (_("Unresolvable or nonpositive repeat count; using 1"));
3932 /* The cons function is going to output this expression once. So we
3933 output it count - 1 times. */
3934 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3935 emit_expr (exp
, nbytes
);
3938 #endif /* REPEAT_CONS_EXPRESSIONS */
3940 /* Parse a floating point number represented as a hex constant. This
3941 permits users to specify the exact bits they want in the floating
3945 hex_float (float_type
, bytes
)
3979 as_bad (_("Unknown floating type type '%c'"), float_type
);
3983 /* It would be nice if we could go through expression to parse the
3984 hex constant, but if we get a bignum it's a pain to sort it into
3985 the buffer correctly. */
3987 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
3991 /* The MRI assembler accepts arbitrary underscores strewn about
3992 through the hex constant, so we ignore them as well. */
3993 if (*input_line_pointer
== '_')
3995 ++input_line_pointer
;
4001 as_warn (_("Floating point constant too large"));
4004 d
= hex_value (*input_line_pointer
) << 4;
4005 ++input_line_pointer
;
4006 while (*input_line_pointer
== '_')
4007 ++input_line_pointer
;
4008 if (hex_p (*input_line_pointer
))
4010 d
+= hex_value (*input_line_pointer
);
4011 ++input_line_pointer
;
4013 if (target_big_endian
)
4016 bytes
[length
- i
- 1] = d
;
4022 if (target_big_endian
)
4023 memset (bytes
+ i
, 0, length
- i
);
4025 memset (bytes
, 0, length
- i
);
4034 * CONStruct some more frag chars of .floats .ffloats etc.
4035 * Makes 0 or more new frags.
4036 * If need_pass_2 == 1, no frags are emitted.
4037 * This understands only floating literals, not expressions. Sorry.
4039 * A floating constant is defined by atof_generic(), except it is preceded
4040 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4041 * reading, I decided to be incompatible. This always tries to give you
4042 * rounded bits to the precision of the pseudo-op. Former AS did premature
4043 * truncatation, restored noisy bits instead of trailing 0s AND gave you
4044 * a choice of 2 flavours of noise according to which of 2 floating-point
4045 * scanners you directed AS to use.
4047 * In: input_line_pointer->whitespace before, or '0' of flonum.
4052 float_cons (float_type
)
4053 /* Clobbers input_line-pointer, checks end-of-line. */
4054 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4057 int length
; /* Number of chars in an object. */
4058 register char *err
; /* Error from scanning floating literal. */
4059 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4061 if (is_it_end_of_statement ())
4063 demand_empty_rest_of_line ();
4067 #ifdef md_flush_pending_output
4068 md_flush_pending_output ();
4073 /* input_line_pointer->1st char of a flonum (we hope!). */
4076 /* Skip any 0{letter} that may be present. Don't even check if the
4077 * letter is legal. Someone may invent a "z" format and this routine
4078 * has no use for such information. Lusers beware: you get
4079 * diagnostics if your input is ill-conditioned.
4081 if (input_line_pointer
[0] == '0'
4082 && isalpha ((unsigned char) input_line_pointer
[1]))
4083 input_line_pointer
+= 2;
4085 /* Accept :xxxx, where the x's are hex digits, for a floating
4086 point with the exact digits specified. */
4087 if (input_line_pointer
[0] == ':')
4089 ++input_line_pointer
;
4090 length
= hex_float (float_type
, temp
);
4093 ignore_rest_of_line ();
4099 err
= md_atof (float_type
, temp
, &length
);
4100 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4104 as_bad (_("Bad floating literal: %s"), err
);
4105 ignore_rest_of_line ();
4116 #ifdef REPEAT_CONS_EXPRESSIONS
4117 if (*input_line_pointer
== ':')
4119 expressionS count_exp
;
4121 ++input_line_pointer
;
4122 expression (&count_exp
);
4123 if (count_exp
.X_op
!= O_constant
4124 || count_exp
.X_add_number
<= 0)
4126 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4129 count
= count_exp
.X_add_number
;
4133 while (--count
>= 0)
4135 p
= frag_more (length
);
4136 memcpy (p
, temp
, (unsigned int) length
);
4141 while (*input_line_pointer
++ == ',');
4143 --input_line_pointer
; /* Put terminator back into stream. */
4144 demand_empty_rest_of_line ();
4145 } /* float_cons() */
4147 /* Return the size of a LEB128 value */
4150 sizeof_sleb128 (value
)
4153 register int size
= 0;
4154 register unsigned byte
;
4158 byte
= (value
& 0x7f);
4159 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4160 Fortunately, we can structure things so that the extra work reduces
4161 to a noop on systems that do things "properly". */
4162 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4165 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4166 || ((value
== -1) && ((byte
& 0x40) != 0))));
4172 sizeof_uleb128 (value
)
4175 register int size
= 0;
4176 register unsigned byte
;
4180 byte
= (value
& 0x7f);
4190 sizeof_leb128 (value
, sign
)
4195 return sizeof_sleb128 ((offsetT
) value
);
4197 return sizeof_uleb128 (value
);
4200 /* Output a LEB128 value. */
4203 output_sleb128 (p
, value
)
4207 register char *orig
= p
;
4212 unsigned byte
= (value
& 0x7f);
4214 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4215 Fortunately, we can structure things so that the extra work reduces
4216 to a noop on systems that do things "properly". */
4217 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4219 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4220 || ((value
== -1) && ((byte
& 0x40) != 0))));
4232 output_uleb128 (p
, value
)
4240 unsigned byte
= (value
& 0x7f);
4243 /* More bytes to follow. */
4254 output_leb128 (p
, value
, sign
)
4260 return output_sleb128 (p
, (offsetT
) value
);
4262 return output_uleb128 (p
, value
);
4265 /* Do the same for bignums. We combine sizeof with output here in that
4266 we don't output for NULL values of P. It isn't really as critical as
4267 for "normal" values that this be streamlined. */
4270 output_big_sleb128 (p
, bignum
, size
)
4272 LITTLENUM_TYPE
*bignum
;
4280 /* Strip leading sign extensions off the bignum. */
4281 while (size
> 0 && bignum
[size
-1] == (LITTLENUM_TYPE
)-1)
4286 if (loaded
< 7 && size
> 0)
4288 val
|= (*bignum
<< loaded
);
4289 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4300 if ((val
== 0 && (byte
& 0x40) == 0)
4301 || (~(val
| ~(((valueT
)1 << loaded
) - 1)) == 0
4302 && (byte
& 0x40) != 0))
4310 while (byte
& 0x80);
4316 output_big_uleb128 (p
, bignum
, size
)
4318 LITTLENUM_TYPE
*bignum
;
4326 /* Strip leading zeros off the bignum. */
4327 /* XXX: Is this needed? */
4328 while (size
> 0 && bignum
[size
-1] == 0)
4333 if (loaded
< 7 && size
> 0)
4335 val
|= (*bignum
<< loaded
);
4336 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4345 if (size
> 0 || val
)
4352 while (byte
& 0x80);
4358 output_big_leb128 (p
, bignum
, size
, sign
)
4360 LITTLENUM_TYPE
*bignum
;
4364 return output_big_sleb128 (p
, bignum
, size
);
4366 return output_big_uleb128 (p
, bignum
, size
);
4369 /* Generate the appropriate fragments for a given expression to emit a
4373 emit_leb128_expr(exp
, sign
)
4377 operatorT op
= exp
->X_op
;
4379 if (op
== O_absent
|| op
== O_illegal
)
4381 as_warn (_("zero assumed for missing expression"));
4382 exp
->X_add_number
= 0;
4385 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4387 as_bad (_("floating point number invalid; zero assumed"));
4388 exp
->X_add_number
= 0;
4391 else if (op
== O_register
)
4393 as_warn (_("register value used as expression"));
4397 if (op
== O_constant
)
4399 /* If we've got a constant, emit the thing directly right now. */
4401 valueT value
= exp
->X_add_number
;
4405 size
= sizeof_leb128 (value
, sign
);
4406 p
= frag_more (size
);
4407 output_leb128 (p
, value
, sign
);
4409 else if (op
== O_big
)
4411 /* O_big is a different sort of constant. */
4416 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4417 p
= frag_more (size
);
4418 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4422 /* Otherwise, we have to create a variable sized fragment and
4423 resolve things later. */
4425 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
)0), 0, sign
,
4426 make_expr_symbol (exp
), 0, (char *) NULL
);
4430 /* Parse the .sleb128 and .uleb128 pseudos. */
4440 emit_leb128_expr (&exp
, sign
);
4441 } while (*input_line_pointer
++ == ',');
4443 input_line_pointer
--;
4444 demand_empty_rest_of_line ();
4450 * We read 0 or more ',' separated, double-quoted strings.
4452 * Caller should have checked need_pass_2 is FALSE because we don't check it.
4457 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4458 /* Checks end-of-line. */
4459 register int append_zero
; /* 0: don't append '\0', else 1 */
4461 register unsigned int c
;
4464 #ifdef md_flush_pending_output
4465 md_flush_pending_output ();
4469 * The following awkward logic is to parse ZERO or more strings,
4470 * comma separated. Recall a string expression includes spaces
4471 * before the opening '\"' and spaces after the closing '\"'.
4472 * We fake a leading ',' if there is (supposed to be)
4473 * a 1st, expression. We keep demanding expressions for each
4476 if (is_it_end_of_statement ())
4478 c
= 0; /* Skip loop. */
4479 ++input_line_pointer
; /* Compensate for end of loop. */
4483 c
= ','; /* Do loop. */
4485 while (c
== ',' || c
== '<' || c
== '"')
4488 switch (*input_line_pointer
)
4491 ++input_line_pointer
; /*->1st char of string. */
4492 start
= input_line_pointer
;
4493 while (is_a_char (c
= next_char_of_string ()))
4495 FRAG_APPEND_1_CHAR (c
);
4499 FRAG_APPEND_1_CHAR (0);
4501 know (input_line_pointer
[-1] == '\"');
4505 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4506 will emit .string with a filename in the .debug section
4507 after a sequence of constants. See the comment in
4508 emit_expr for the sequence. emit_expr will set
4509 dwarf_file_string to non-zero if this string might be a
4510 source file name. */
4511 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4512 dwarf_file_string
= 0;
4513 else if (dwarf_file_string
)
4515 c
= input_line_pointer
[-1];
4516 input_line_pointer
[-1] = '\0';
4517 listing_source_file (start
);
4518 input_line_pointer
[-1] = c
;
4525 input_line_pointer
++;
4526 c
= get_single_number ();
4527 FRAG_APPEND_1_CHAR (c
);
4528 if (*input_line_pointer
!= '>')
4530 as_bad (_("Expected <nn>"));
4532 input_line_pointer
++;
4535 input_line_pointer
++;
4539 c
= *input_line_pointer
;
4542 demand_empty_rest_of_line ();
4545 /* FIXME-SOMEDAY: I had trouble here on characters with the
4546 high bits set. We'll probably also have trouble with
4547 multibyte chars, wide chars, etc. Also be careful about
4548 returning values bigger than 1 byte. xoxorich. */
4551 next_char_of_string ()
4553 register unsigned int c
;
4555 c
= *input_line_pointer
++ & CHAR_MASK
;
4563 as_warn (_("Unterminated string: Newline inserted."));
4564 bump_line_counters ();
4567 #ifndef NO_STRING_ESCAPES
4569 switch (c
= *input_line_pointer
++)
4597 break; /* As itself. */
4613 for (i
= 0, number
= 0; isdigit (c
) && i
< 3; c
= *input_line_pointer
++, i
++)
4615 number
= number
* 8 + c
- '0';
4619 --input_line_pointer
;
4628 c
= *input_line_pointer
++;
4629 while (isxdigit (c
))
4632 number
= number
* 16 + c
- '0';
4633 else if (isupper (c
))
4634 number
= number
* 16 + c
- 'A' + 10;
4636 number
= number
* 16 + c
- 'a' + 10;
4637 c
= *input_line_pointer
++;
4640 --input_line_pointer
;
4645 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4646 as_warn (_("Unterminated string: Newline inserted."));
4648 bump_line_counters ();
4653 #ifdef ONLY_STANDARD_ESCAPES
4654 as_bad (_("Bad escaped character in string, '?' assumed"));
4656 #endif /* ONLY_STANDARD_ESCAPES */
4659 } /* switch on escaped char */
4661 #endif /* ! defined (NO_STRING_ESCAPES) */
4665 } /* switch on char */
4667 } /* next_char_of_string() */
4670 get_segmented_expression (expP
)
4671 register expressionS
*expP
;
4673 register segT retval
;
4675 retval
= expression (expP
);
4676 if (expP
->X_op
== O_illegal
4677 || expP
->X_op
== O_absent
4678 || expP
->X_op
== O_big
)
4680 as_bad (_("expected address expression; zero assumed"));
4681 expP
->X_op
= O_constant
;
4682 expP
->X_add_number
= 0;
4683 retval
= absolute_section
;
4689 get_known_segmented_expression (expP
)
4690 register expressionS
*expP
;
4692 register segT retval
;
4694 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4696 /* There is no easy way to extract the undefined symbol from the
4698 if (expP
->X_add_symbol
!= NULL
4699 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4700 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4701 S_GET_NAME (expP
->X_add_symbol
));
4703 as_warn (_("some symbol undefined; zero assumed"));
4704 retval
= absolute_section
;
4705 expP
->X_op
= O_constant
;
4706 expP
->X_add_number
= 0;
4708 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4710 } /* get_known_segmented_expression() */
4713 get_absolute_expression ()
4718 if (exp
.X_op
!= O_constant
)
4720 if (exp
.X_op
!= O_absent
)
4721 as_bad (_("bad or irreducible absolute expression; zero assumed"));
4722 exp
.X_add_number
= 0;
4724 return exp
.X_add_number
;
4727 char /* return terminator */
4728 get_absolute_expression_and_terminator (val_pointer
)
4729 long *val_pointer
; /* return value of expression */
4731 /* FIXME: val_pointer should probably be offsetT *. */
4732 *val_pointer
= (long) get_absolute_expression ();
4733 return (*input_line_pointer
++);
4737 * demand_copy_C_string()
4739 * Like demand_copy_string, but return NULL if the string contains any '\0's.
4740 * Give a warning if that happens.
4743 demand_copy_C_string (len_pointer
)
4748 if ((s
= demand_copy_string (len_pointer
)) != 0)
4752 for (len
= *len_pointer
; len
> 0; len
--)
4759 as_bad (_("This string may not contain \'\\0\'"));
4767 * demand_copy_string()
4769 * Demand string, but return a safe (=private) copy of the string.
4770 * Return NULL if we can't read a string here.
4773 demand_copy_string (lenP
)
4776 register unsigned int c
;
4782 if (*input_line_pointer
== '\"')
4784 input_line_pointer
++; /* Skip opening quote. */
4786 while (is_a_char (c
= next_char_of_string ()))
4788 obstack_1grow (¬es
, c
);
4791 /* JF this next line is so demand_copy_C_string will return a
4792 null terminated string. */
4793 obstack_1grow (¬es
, '\0');
4794 retval
= obstack_finish (¬es
);
4798 as_warn (_("Missing string"));
4800 ignore_rest_of_line ();
4804 } /* demand_copy_string() */
4807 * is_it_end_of_statement()
4809 * In: Input_line_pointer->next character.
4811 * Do: Skip input_line_pointer over all whitespace.
4813 * Out: 1 if input_line_pointer->end-of-line.
4816 is_it_end_of_statement ()
4819 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4820 } /* is_it_end_of_statement() */
4823 equals (sym_name
, reassign
)
4827 register symbolS
*symbolP
; /* symbol we are working with */
4831 input_line_pointer
++;
4832 if (*input_line_pointer
== '=')
4833 input_line_pointer
++;
4835 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4836 input_line_pointer
++;
4839 stop
= mri_comment_field (&stopc
);
4841 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4843 /* Turn '. = mumble' into a .org mumble */
4844 register segT segment
;
4847 segment
= get_known_segmented_expression (&exp
);
4849 do_org (segment
, &exp
, 0);
4853 symbolP
= symbol_find_or_make (sym_name
);
4854 /* Permit register names to be redefined. */
4856 && S_IS_DEFINED (symbolP
)
4857 && S_GET_SEGMENT (symbolP
) != reg_section
)
4858 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
4859 pseudo_set (symbolP
);
4864 ignore_rest_of_line (); /* check garbage after the expression */
4865 mri_comment_end (stop
, stopc
);
4869 /* .include -- include a file at this point. */
4874 int arg ATTRIBUTE_UNUSED
;
4882 if (! flag_m68k_mri
)
4884 filename
= demand_copy_string (&i
);
4885 if (filename
== NULL
)
4887 /* demand_copy_string has already printed an error and
4888 called ignore_rest_of_line. */
4896 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
4897 && *input_line_pointer
!= ' '
4898 && *input_line_pointer
!= '\t')
4900 obstack_1grow (¬es
, *input_line_pointer
);
4901 ++input_line_pointer
;
4904 obstack_1grow (¬es
, '\0');
4905 filename
= obstack_finish (¬es
);
4906 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
4907 ++input_line_pointer
;
4909 demand_empty_rest_of_line ();
4910 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
4911 for (i
= 0; i
< include_dir_count
; i
++)
4913 strcpy (path
, include_dirs
[i
]);
4915 strcat (path
, filename
);
4916 if (0 != (try = fopen (path
, "r")))
4925 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
4926 register_dependency (path
);
4927 newbuf
= input_scrub_include_file (path
, input_line_pointer
);
4928 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
4932 add_include_dir (path
)
4937 if (include_dir_count
== 0)
4939 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
4940 include_dirs
[0] = "."; /* Current dir */
4941 include_dir_count
= 2;
4945 include_dir_count
++;
4946 include_dirs
= (char **) realloc (include_dirs
,
4947 include_dir_count
* sizeof (*include_dirs
));
4950 include_dirs
[include_dir_count
- 1] = path
; /* New one */
4953 if (i
> include_dir_maxlen
)
4954 include_dir_maxlen
= i
;
4955 } /* add_include_dir() */
4957 /* Output debugging information to denote the source file. */
4960 generate_file_debug ()
4962 if (debug_type
== DEBUG_STABS
)
4963 stabs_generate_asm_file ();
4966 /* Output line number debugging information for the current source line. */
4969 generate_lineno_debug ()
4971 #ifdef ECOFF_DEBUGGING
4972 /* ECOFF assemblers automatically generate debugging information.
4973 FIXME: This should probably be handled elsewhere. */
4974 if (debug_type
== DEBUG_UNSPECIFIED
)
4976 if (ECOFF_DEBUGGING
&& ecoff_no_current_file ())
4977 debug_type
= DEBUG_ECOFF
;
4979 debug_type
= DEBUG_NONE
;
4985 case DEBUG_UNSPECIFIED
:
4989 stabs_generate_asm_lineno ();
4992 ecoff_generate_asm_lineno ();
5001 /* Output debugging information to mark a function entry point or end point.
5002 END_P is zero for .func, and non-zero for .endfunc. */
5008 do_s_func (end_p
, NULL
);
5011 /* Subroutine of s_func so targets can choose a different default prefix.
5012 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5015 do_s_func (end_p
, default_prefix
)
5017 const char *default_prefix
;
5019 /* Record the current function so that we can issue an error message for
5020 misplaced .func,.endfunc, and also so that .endfunc needs no
5022 static char *current_name
;
5023 static char *current_label
;
5027 if (current_name
== NULL
)
5029 as_bad (_("missing .func"));
5030 ignore_rest_of_line ();
5034 if (debug_type
== DEBUG_STABS
)
5035 stabs_generate_asm_endfunc (current_name
, current_label
);
5037 current_name
= current_label
= NULL
;
5044 if (current_name
!= NULL
)
5046 as_bad (_(".endfunc missing for previous .func"));
5047 ignore_rest_of_line ();
5051 name
= input_line_pointer
;
5052 delim1
= get_symbol_end ();
5053 name
= xstrdup (name
);
5054 *input_line_pointer
= delim1
;
5056 if (*input_line_pointer
!= ',')
5059 asprintf (&label
, "%s%s", default_prefix
, name
);
5062 char leading_char
= 0;
5063 #ifdef BFD_ASSEMBLER
5064 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5066 /* Missing entry point, use function's name with the leading
5069 asprintf (&label
, "%c%s", leading_char
, name
);
5076 ++input_line_pointer
;
5078 label
= input_line_pointer
;
5079 delim2
= get_symbol_end ();
5080 label
= xstrdup (label
);
5081 *input_line_pointer
= delim2
;
5084 if (debug_type
== DEBUG_STABS
)
5085 stabs_generate_asm_func (name
, label
);
5087 current_name
= name
;
5088 current_label
= label
;
5091 demand_empty_rest_of_line ();
5096 int arg ATTRIBUTE_UNUSED
;
5098 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5100 ++input_line_pointer
;
5102 ++input_line_pointer
;
5107 read_print_statistics (file
)
5110 hash_print_statistics (file
, "pseudo-op table", po_hash
);