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 ();
554 #ifdef LABELS_WITHOUT_COLONS
559 /* Text at the start of a line must be a label, we
560 run down and stick a colon in. */
561 if (is_name_beginner (*input_line_pointer
))
563 char *line_start
= input_line_pointer
;
568 HANDLE_CONDITIONAL_ASSEMBLY ();
570 c
= get_symbol_end ();
572 /* In MRI mode, the EQU and MACRO pseudoops must
573 be handled specially. */
577 char *rest
= input_line_pointer
+ 1;
581 if (*rest
== ' ' || *rest
== '\t')
583 if ((strncasecmp (rest
, "EQU", 3) == 0
584 || strncasecmp (rest
, "SET", 3) == 0)
585 && (rest
[3] == ' ' || rest
[3] == '\t'))
587 input_line_pointer
= rest
+ 3;
589 strncasecmp (rest
, "SET", 3) == 0);
592 if (strncasecmp (rest
, "MACRO", 5) == 0
595 || is_end_of_line
[(unsigned char) rest
[5]]))
599 /* In MRI mode, we need to handle the MACRO
600 pseudo-op specially: we don't want to put the
601 symbol in the symbol table. */
602 if (! mri_line_macro
)
603 line_label
= colon (line_start
);
605 line_label
= symbol_create (line_start
,
610 *input_line_pointer
= c
;
612 input_line_pointer
++;
618 * We are at the begining of a line, or similar place.
619 * We expect a well-formed assembler statement.
620 * A "symbol-name:" is a statement.
622 * Depending on what compiler is used, the order of these tests
623 * may vary to catch most common case 1st.
624 * Each test is independent of all other tests at the (top) level.
625 * PLEASE make a compiler that doesn't use this assembler.
626 * It is crufty to waste a compiler's time encoding things for this
627 * assembler, which then wastes more time decoding it.
628 * (And communicating via (linear) files is silly!
629 * If you must pass stuff, please pass a tree!)
631 if ((c
= *input_line_pointer
++) == '\t'
636 c
= *input_line_pointer
++;
638 know (c
!= ' '); /* No further leading whitespace. */
641 /* If listing is on, and we are expanding a macro, then give
642 the listing code the contents of the expanded line. */
645 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
650 /* Find the end of the current expanded macro line. */
651 for (s
= input_line_pointer
-1; *s
; ++s
)
652 if (is_end_of_line
[(unsigned char) *s
])
655 /* Copy it for safe keeping. Also give an indication of
656 how much macro nesting is involved at this point. */
657 len
= s
- (input_line_pointer
-1);
658 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
659 memset (copy
, '>', macro_nest
);
660 copy
[macro_nest
] = ' ';
661 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
-1, len
);
662 copy
[macro_nest
+1+len
] = '\0';
664 /* Install the line with the listing facility. */
665 listing_newline (copy
);
668 listing_newline (NULL
);
673 * C is the 1st significant character.
674 * Input_line_pointer points after that character.
676 if (is_name_beginner (c
))
678 /* want user-defined label or pseudo/opcode */
679 HANDLE_CONDITIONAL_ASSEMBLY ();
681 s
= --input_line_pointer
;
682 c
= get_symbol_end (); /* name's delimiter */
684 * C is character after symbol.
685 * That character's place in the input line is now '\0'.
686 * S points to the beginning of the symbol.
687 * [In case of pseudo-op, s->'.'.]
688 * Input_line_pointer->'\0' where c was.
690 if (TC_START_LABEL(c
, input_line_pointer
))
694 char *rest
= input_line_pointer
+ 1;
696 /* In MRI mode, \tsym: set 0 is permitted. */
700 if (*rest
== ' ' || *rest
== '\t')
702 if ((strncasecmp (rest
, "EQU", 3) == 0
703 || strncasecmp (rest
, "SET", 3) == 0)
704 && (rest
[3] == ' ' || rest
[3] == '\t'))
706 input_line_pointer
= rest
+ 3;
712 line_label
= colon (s
); /* user-defined label */
713 *input_line_pointer
++ = ':'; /* Put ':' back for error messages' sake. */
714 /* Input_line_pointer->after ':'. */
720 || ((c
== ' ' || c
== '\t')
721 && input_line_pointer
[1] == '='
722 #ifdef TC_EQUAL_IN_INSN
723 && ! TC_EQUAL_IN_INSN (c
, input_line_pointer
)
728 demand_empty_rest_of_line ();
731 { /* expect pseudo-op or machine instruction */
734 #define IGNORE_OPCODE_CASE
735 #ifdef IGNORE_OPCODE_CASE
740 if (isupper ((unsigned char) *s2
))
753 /* The MRI assembler and the m88k use pseudo-ops
755 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
756 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
761 || (! flag_m68k_mri
&& *s
== '.'))
766 * WARNING: c has next char, which may be end-of-line.
767 * We lookup the pseudo-op table with s+1 because we
768 * already know that the pseudo-op begins with a '.'.
772 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
774 /* In MRI mode, we may need to insert an
775 automatic alignment directive. What a hack
777 if (mri_pending_align
779 || ! ((pop
->poc_handler
== cons
780 && pop
->poc_val
== 1)
781 || (pop
->poc_handler
== s_space
782 && pop
->poc_val
== 1)
783 #ifdef tc_conditional_pseudoop
784 || tc_conditional_pseudoop (pop
)
786 || pop
->poc_handler
== s_if
787 || pop
->poc_handler
== s_ifdef
788 || pop
->poc_handler
== s_ifc
789 || pop
->poc_handler
== s_ifeqs
790 || pop
->poc_handler
== s_else
791 || pop
->poc_handler
== s_endif
792 || pop
->poc_handler
== s_globl
793 || pop
->poc_handler
== s_ignore
)))
795 do_align (1, (char *) NULL
, 0, 0);
796 mri_pending_align
= 0;
797 if (line_label
!= NULL
)
799 symbol_set_frag (line_label
, frag_now
);
800 S_SET_VALUE (line_label
, frag_now_fix ());
804 /* Print the error msg now, while we still can */
807 as_bad (_("Unknown pseudo-op: `%s'"), s
);
808 *input_line_pointer
= c
;
813 /* Put it back for error messages etc. */
814 *input_line_pointer
= c
;
815 /* The following skip of whitespace is compulsory.
816 A well shaped space is sometimes all that separates
817 keyword from operands. */
818 if (c
== ' ' || c
== '\t')
819 input_line_pointer
++;
821 * Input_line is restored.
822 * Input_line_pointer->1st non-blank char
823 * after pseudo-operation.
825 (*pop
->poc_handler
) (pop
->poc_val
);
827 /* If that was .end, just get out now. */
828 if (pop
->poc_handler
== s_end
)
834 #ifdef QUOTES_IN_INSN
838 /* WARNING: c has char, which may be end-of-line. */
839 /* Also: input_line_pointer->`\0` where c was. */
840 *input_line_pointer
= c
;
841 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
843 #ifdef TC_EOL_IN_INSN
844 || TC_EOL_IN_INSN (input_line_pointer
)
848 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
850 #ifdef QUOTES_IN_INSN
853 else if (*input_line_pointer
== '"')
855 else if (*input_line_pointer
== '\\')
858 input_line_pointer
++;
861 c
= *input_line_pointer
;
862 *input_line_pointer
= '\0';
864 generate_lineno_debug ();
871 if (check_macro (s
, &out
, '\0', &err
))
875 *input_line_pointer
++ = c
;
876 input_scrub_include_sb (&out
,
880 input_scrub_next_buffer (&input_line_pointer
);
885 if (mri_pending_align
)
887 do_align (1, (char *) NULL
, 0, 0);
888 mri_pending_align
= 0;
889 if (line_label
!= NULL
)
891 symbol_set_frag (line_label
, frag_now
);
892 S_SET_VALUE (line_label
, frag_now_fix ());
896 md_assemble (s
); /* Assemble 1 instruction. */
898 *input_line_pointer
++ = c
;
900 /* We resume loop AFTER the end-of-line from
905 } /* if (is_name_beginner(c) */
908 /* Empty statement? */
909 if (is_end_of_line
[(unsigned char) c
])
912 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
913 && isdigit ((unsigned char) c
))
915 /* local label ("4:") */
916 char *backup
= input_line_pointer
;
918 HANDLE_CONDITIONAL_ASSEMBLY ();
922 while (isdigit ((unsigned char) *input_line_pointer
))
924 temp
= (temp
* 10) + *input_line_pointer
- '0';
925 ++input_line_pointer
;
926 } /* read the whole number */
928 if (LOCAL_LABELS_DOLLAR
929 && *input_line_pointer
== '$'
930 && *(input_line_pointer
+ 1) == ':')
932 input_line_pointer
+= 2;
934 if (dollar_label_defined (temp
))
936 as_fatal (_("label \"%d$\" redefined"), temp
);
939 define_dollar_label (temp
);
940 colon (dollar_label_name (temp
, 0));
945 && *input_line_pointer
++ == ':')
947 fb_label_instance_inc (temp
);
948 colon (fb_label_name (temp
, 0));
952 input_line_pointer
= backup
;
953 } /* local label ("4:") */
955 if (c
&& strchr (line_comment_chars
, c
))
956 { /* Its a comment. Better say APP or NO_APP */
960 unsigned int new_length
;
963 bump_line_counters ();
964 s
= input_line_pointer
;
965 if (strncmp (s
, "APP\n", 4))
966 continue; /* We ignore it */
969 ends
= strstr (s
, "#NO_APP\n");
973 unsigned int tmp_len
;
976 /* The end of the #APP wasn't in this buffer. We
977 keep reading in buffers until we find the #NO_APP
978 that goes with this #APP There is one. The specs
980 tmp_len
= buffer_limit
- s
;
981 tmp_buf
= xmalloc (tmp_len
+ 1);
982 memcpy (tmp_buf
, s
, tmp_len
);
985 new_tmp
= input_scrub_next_buffer (&buffer
);
989 buffer_limit
= new_tmp
;
990 input_line_pointer
= buffer
;
991 ends
= strstr (buffer
, "#NO_APP\n");
995 num
= buffer_limit
- buffer
;
997 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
998 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
1003 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1011 input_line_pointer
= ends
+ 8;
1015 scrub_string_end
= ends
;
1017 new_length
= ends
- s
;
1018 new_buf
= (char *) xmalloc (new_length
);
1025 space
= (new_buf
+ new_length
) - new_tmp
;
1026 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1034 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1035 new_tmp
= new_buf
+ new_length
;
1041 old_buffer
= buffer
;
1042 old_input
= input_line_pointer
;
1043 old_limit
= buffer_limit
;
1045 input_line_pointer
= new_buf
;
1046 buffer_limit
= new_tmp
;
1050 HANDLE_CONDITIONAL_ASSEMBLY ();
1052 #ifdef tc_unrecognized_line
1053 if (tc_unrecognized_line (c
))
1057 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
1058 input_line_pointer
--; /* Report unknown char as ignored. */
1059 ignore_rest_of_line ();
1060 } /* while (input_line_pointer<buffer_limit) */
1062 #ifdef md_after_pass_hook
1063 md_after_pass_hook ();
1069 bump_line_counters ();
1072 buffer
= old_buffer
;
1073 input_line_pointer
= old_input
;
1074 buffer_limit
= old_limit
;
1079 } /* while (more buffers to scan) */
1086 input_scrub_close (); /* Close the input file */
1089 /* For most MRI pseudo-ops, the line actually ends at the first
1090 nonquoted space. This function looks for that point, stuffs a null
1091 in, and sets *STOPCP to the character that used to be there, and
1092 returns the location.
1094 Until I hear otherwise, I am going to assume that this is only true
1095 for the m68k MRI assembler. */
1098 mri_comment_field (stopcp
)
1106 know (flag_m68k_mri
);
1108 for (s
= input_line_pointer
;
1109 ((! is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1114 inquote
= ! inquote
;
1124 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
1134 /* Skip to the end of an MRI comment field. */
1137 mri_comment_end (stop
, stopc
)
1143 input_line_pointer
= stop
;
1145 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1146 ++input_line_pointer
;
1151 int ignore ATTRIBUTE_UNUSED
;
1153 as_fatal (_(".abort detected. Abandoning ship."));
1156 /* Guts of .align directive. N is the power of two to which to align.
1157 FILL may be NULL, or it may point to the bytes of the fill pattern.
1158 LEN is the length of whatever FILL points to, if anything. MAX is
1159 the maximum number of characters to skip when doing the alignment,
1160 or 0 if there is no maximum. */
1163 do_align (n
, fill
, len
, max
)
1172 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1177 if (subseg_text_p (now_seg
))
1178 default_fill
= NOP_OPCODE
;
1181 fill
= &default_fill
;
1185 /* Only make a frag if we HAVE to. . . */
1186 if (n
!= 0 && !need_pass_2
)
1189 frag_align (n
, *fill
, max
);
1191 frag_align_pattern (n
, fill
, len
, max
);
1195 just_record_alignment
:
1198 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1201 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1202 (in bytes). A negative ARG is the negative of the length of the
1203 fill pattern. BYTES_P is non-zero if the alignment value should be
1204 interpreted as the byte boundary, rather than the power of 2. */
1207 s_align (arg
, bytes_p
)
1211 register unsigned int align
;
1219 stop
= mri_comment_field (&stopc
);
1221 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1226 align
= arg
; /* Default value from pseudo-op table */
1230 align
= get_absolute_expression ();
1236 /* Convert to a power of 2. */
1241 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1244 as_bad (_("Alignment not a power of 2"));
1252 as_bad (_("Alignment too large: %u assumed"), align
);
1255 if (*input_line_pointer
!= ',')
1262 ++input_line_pointer
;
1263 if (*input_line_pointer
== ',')
1267 fill
= get_absolute_expression ();
1272 if (*input_line_pointer
!= ',')
1276 ++input_line_pointer
;
1277 max
= get_absolute_expression ();
1284 as_warn (_("expected fill pattern missing"));
1285 do_align (align
, (char *) NULL
, 0, max
);
1300 do_align (align
, &fill_char
, fill_len
, max
);
1306 if ((size_t) fill_len
> sizeof ab
)
1308 md_number_to_chars (ab
, fill
, fill_len
);
1309 do_align (align
, ab
, fill_len
, max
);
1313 demand_empty_rest_of_line ();
1316 mri_comment_end (stop
, stopc
);
1319 /* Handle the .align pseudo-op on machines where ".align 4" means
1320 align to a 4 byte boundary. */
1329 /* Handle the .align pseudo-op on machines where ".align 4" means align
1330 to a 2**4 boundary. */
1341 int ignore ATTRIBUTE_UNUSED
;
1343 register char *name
;
1347 register symbolS
*symbolP
;
1352 stop
= mri_comment_field (&stopc
);
1354 name
= input_line_pointer
;
1355 c
= get_symbol_end ();
1356 /* just after name is now '\0' */
1357 p
= input_line_pointer
;
1360 if (*input_line_pointer
!= ',')
1362 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1363 ignore_rest_of_line ();
1365 mri_comment_end (stop
, stopc
);
1368 input_line_pointer
++; /* skip ',' */
1369 if ((temp
= get_absolute_expression ()) < 0)
1371 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
1372 ignore_rest_of_line ();
1374 mri_comment_end (stop
, stopc
);
1378 symbolP
= symbol_find_or_make (name
);
1380 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
1382 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1383 S_GET_NAME (symbolP
));
1384 ignore_rest_of_line ();
1386 mri_comment_end (stop
, stopc
);
1389 if (S_GET_VALUE (symbolP
))
1391 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1392 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
1393 S_GET_NAME (symbolP
),
1394 (long) S_GET_VALUE (symbolP
),
1399 S_SET_VALUE (symbolP
, (valueT
) temp
);
1400 S_SET_EXTERNAL (symbolP
);
1404 extern int flag_one
;
1405 if ( (!temp
) || !flag_one
)
1406 S_GET_OTHER(symbolP
) = const_flag
;
1408 #endif /* not OBJ_VMS */
1409 know (symbolP
->sy_frag
== &zero_address_frag
);
1411 demand_empty_rest_of_line ();
1414 mri_comment_end (stop
, stopc
);
1417 /* The MRI COMMON pseudo-op. We handle this by creating a common
1418 symbol with the appropriate name. We make s_space do the right
1419 thing by increasing the size. */
1422 s_mri_common (small
)
1423 int small ATTRIBUTE_UNUSED
;
1439 stop
= mri_comment_field (&stopc
);
1443 name
= input_line_pointer
;
1444 if (! isdigit ((unsigned char) *name
))
1445 c
= get_symbol_end ();
1450 ++input_line_pointer
;
1452 while (isdigit ((unsigned char) *input_line_pointer
));
1453 c
= *input_line_pointer
;
1454 *input_line_pointer
= '\0';
1456 if (line_label
!= NULL
)
1458 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1459 + (input_line_pointer
- name
)
1461 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1466 sym
= symbol_find_or_make (name
);
1467 *input_line_pointer
= c
;
1471 if (*input_line_pointer
!= ',')
1475 ++input_line_pointer
;
1476 align
= get_absolute_expression ();
1479 if (S_IS_DEFINED (sym
) && ! S_IS_COMMON (sym
))
1481 as_bad (_("attempt to re-define symbol `%s'"), S_GET_NAME (sym
));
1482 ignore_rest_of_line ();
1483 mri_comment_end (stop
, stopc
);
1487 S_SET_EXTERNAL (sym
);
1488 mri_common_symbol
= sym
;
1492 S_SET_ALIGN (sym
, align
);
1495 if (line_label
!= NULL
)
1498 exp
.X_op
= O_symbol
;
1499 exp
.X_add_symbol
= sym
;
1500 exp
.X_add_number
= 0;
1501 symbol_set_value_expression (line_label
, &exp
);
1502 symbol_set_frag (line_label
, &zero_address_frag
);
1503 S_SET_SEGMENT (line_label
, expr_section
);
1506 /* FIXME: We just ignore the small argument, which distinguishes
1507 COMMON and COMMON.S. I don't know what we can do about it. */
1509 /* Ignore the type and hptype. */
1510 if (*input_line_pointer
== ',')
1511 input_line_pointer
+= 2;
1512 if (*input_line_pointer
== ',')
1513 input_line_pointer
+= 2;
1515 demand_empty_rest_of_line ();
1517 mri_comment_end (stop
, stopc
);
1522 int ignore ATTRIBUTE_UNUSED
;
1527 temp
= get_absolute_expression ();
1528 if (flag_readonly_data_in_text
)
1530 section
= text_section
;
1534 section
= data_section
;
1536 subseg_set (section
, (subsegT
) temp
);
1541 demand_empty_rest_of_line ();
1544 /* Handle the .appfile pseudo-op. This is automatically generated by
1545 do_scrub_chars when a preprocessor # line comment is seen with a
1546 file name. This default definition may be overridden by the object
1547 or CPU specific pseudo-ops. This function is also the default
1548 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1552 s_app_file (appfile
)
1558 /* Some assemblers tolerate immediately following '"' */
1559 if ((s
= demand_copy_string (&length
)) != 0)
1561 /* If this is a fake .appfile, a fake newline was inserted into
1562 the buffer. Passing -2 to new_logical_line tells it to
1565 = (! new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1567 /* In MRI mode, the preprocessor may have inserted an extraneous
1570 && *input_line_pointer
== '\''
1571 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1572 ++input_line_pointer
;
1574 demand_empty_rest_of_line ();
1579 listing_source_file (s
);
1581 register_dependency (s
);
1589 /* Handle the .appline pseudo-op. This is automatically generated by
1590 do_scrub_chars when a preprocessor # line comment is seen. This
1591 default definition may be overridden by the object or CPU specific
1596 int ignore ATTRIBUTE_UNUSED
;
1600 /* The given number is that of the next line. */
1601 l
= get_absolute_expression () - 1;
1603 /* Some of the back ends can't deal with non-positive line numbers.
1604 Besides, it's silly. */
1605 as_warn (_("Line numbers must be positive; line number %d rejected."), l
+1);
1608 new_logical_line ((char *) NULL
, l
);
1611 listing_source_line (l
);
1614 demand_empty_rest_of_line ();
1617 /* Handle the .end pseudo-op. Actually, the real work is done in
1618 read_a_source_file. */
1622 int ignore ATTRIBUTE_UNUSED
;
1626 /* The MRI assembler permits the start symbol to follow .end,
1627 but we don't support that. */
1629 if (! is_end_of_line
[(unsigned char) *input_line_pointer
]
1630 && *input_line_pointer
!= '*'
1631 && *input_line_pointer
!= '!')
1632 as_warn (_("start address not supported"));
1636 /* Handle the .err pseudo-op. */
1640 int ignore ATTRIBUTE_UNUSED
;
1642 as_bad (_(".err encountered"));
1643 demand_empty_rest_of_line ();
1646 /* Handle the MRI fail pseudo-op. */
1650 int ignore ATTRIBUTE_UNUSED
;
1657 stop
= mri_comment_field (&stopc
);
1659 temp
= get_absolute_expression ();
1661 as_warn (_(".fail %ld encountered"), (long) temp
);
1663 as_bad (_(".fail %ld encountered"), (long) temp
);
1665 demand_empty_rest_of_line ();
1668 mri_comment_end (stop
, stopc
);
1673 int ignore ATTRIBUTE_UNUSED
;
1675 expressionS rep_exp
;
1677 register long fill
= 0;
1680 #ifdef md_flush_pending_output
1681 md_flush_pending_output ();
1684 get_known_segmented_expression (&rep_exp
);
1685 if (*input_line_pointer
== ',')
1687 input_line_pointer
++;
1688 size
= get_absolute_expression ();
1689 if (*input_line_pointer
== ',')
1691 input_line_pointer
++;
1692 fill
= get_absolute_expression ();
1696 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1697 #define BSD_FILL_SIZE_CROCK_8 (8)
1698 if (size
> BSD_FILL_SIZE_CROCK_8
)
1700 as_warn (_(".fill size clamped to %d."), BSD_FILL_SIZE_CROCK_8
);
1701 size
= BSD_FILL_SIZE_CROCK_8
;
1705 as_warn (_("Size negative: .fill ignored."));
1708 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1710 if (rep_exp
.X_add_number
< 0)
1711 as_warn (_("Repeat < 0, .fill ignored"));
1715 if (size
&& !need_pass_2
)
1717 if (rep_exp
.X_op
== O_constant
)
1719 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1720 (relax_substateT
) 0, (symbolS
*) 0,
1721 (offsetT
) rep_exp
.X_add_number
,
1726 /* We don't have a constant repeat count, so we can't use
1727 rs_fill. We can get the same results out of rs_space,
1728 but its argument is in bytes, so we must multiply the
1729 repeat count by size. */
1732 rep_sym
= make_expr_symbol (&rep_exp
);
1735 expressionS size_exp
;
1736 size_exp
.X_op
= O_constant
;
1737 size_exp
.X_add_number
= size
;
1739 rep_exp
.X_op
= O_multiply
;
1740 rep_exp
.X_add_symbol
= rep_sym
;
1741 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1742 rep_exp
.X_add_number
= 0;
1743 rep_sym
= make_expr_symbol (&rep_exp
);
1746 p
= frag_var (rs_space
, (int) size
, (int) size
,
1747 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1749 memset (p
, 0, (unsigned int) size
);
1750 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1751 * flavoured AS. The following bizzare behaviour is to be
1752 * compatible with above. I guess they tried to take up to 8
1753 * bytes from a 4-byte expression and they forgot to sign
1754 * extend. Un*x Sux. */
1755 #define BSD_FILL_SIZE_CROCK_4 (4)
1756 md_number_to_chars (p
, (valueT
) fill
,
1757 (size
> BSD_FILL_SIZE_CROCK_4
1758 ? BSD_FILL_SIZE_CROCK_4
1760 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1761 * but emits no error message because it seems a legal thing to do.
1762 * It is a degenerate case of .fill but could be emitted by a compiler.
1765 demand_empty_rest_of_line ();
1770 int ignore ATTRIBUTE_UNUSED
;
1779 stop
= mri_comment_field (&stopc
);
1783 name
= input_line_pointer
;
1784 c
= get_symbol_end ();
1785 symbolP
= symbol_find_or_make (name
);
1786 S_SET_EXTERNAL (symbolP
);
1788 *input_line_pointer
= c
;
1790 c
= *input_line_pointer
;
1793 input_line_pointer
++;
1795 if (*input_line_pointer
== '\n')
1801 demand_empty_rest_of_line ();
1804 mri_comment_end (stop
, stopc
);
1807 /* Handle the MRI IRP and IRPC pseudo-ops. */
1819 as_where (&file
, &line
);
1822 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1823 sb_add_char (&s
, *input_line_pointer
++);
1827 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1829 as_bad_where (file
, line
, "%s", err
);
1833 input_scrub_include_sb (&out
, input_line_pointer
);
1835 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1838 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1839 the section to only be linked once. However, this is not supported
1840 by most object file formats. This takes an optional argument,
1841 which is what to do about duplicates. */
1845 int ignore ATTRIBUTE_UNUSED
;
1847 enum linkonce_type type
;
1851 type
= LINKONCE_DISCARD
;
1853 if (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1858 s
= input_line_pointer
;
1859 c
= get_symbol_end ();
1860 if (strcasecmp (s
, "discard") == 0)
1861 type
= LINKONCE_DISCARD
;
1862 else if (strcasecmp (s
, "one_only") == 0)
1863 type
= LINKONCE_ONE_ONLY
;
1864 else if (strcasecmp (s
, "same_size") == 0)
1865 type
= LINKONCE_SAME_SIZE
;
1866 else if (strcasecmp (s
, "same_contents") == 0)
1867 type
= LINKONCE_SAME_CONTENTS
;
1869 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1871 *input_line_pointer
= c
;
1874 #ifdef obj_handle_link_once
1875 obj_handle_link_once (type
);
1876 #else /* ! defined (obj_handle_link_once) */
1877 #ifdef BFD_ASSEMBLER
1881 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1882 as_warn (_(".linkonce is not supported for this object file format"));
1884 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1885 flags
|= SEC_LINK_ONCE
;
1890 case LINKONCE_DISCARD
:
1891 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1893 case LINKONCE_ONE_ONLY
:
1894 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1896 case LINKONCE_SAME_SIZE
:
1897 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1899 case LINKONCE_SAME_CONTENTS
:
1900 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1903 if (! bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1904 as_bad (_("bfd_set_section_flags: %s"),
1905 bfd_errmsg (bfd_get_error ()));
1907 #else /* ! defined (BFD_ASSEMBLER) */
1908 as_warn (_(".linkonce is not supported for this object file format"));
1909 #endif /* ! defined (BFD_ASSEMBLER) */
1910 #endif /* ! defined (obj_handle_link_once) */
1912 demand_empty_rest_of_line ();
1916 s_lcomm_internal (needs_align
, bytes_p
)
1917 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1918 (alignment); 0 if it was an ".lcomm" (2 args only) */
1920 /* 1 if the alignment value should be interpreted as the byte boundary,
1921 rather than the power of 2. */
1924 register char *name
;
1928 register symbolS
*symbolP
;
1929 segT current_seg
= now_seg
;
1930 subsegT current_subseg
= now_subseg
;
1931 const int max_alignment
= 15;
1933 segT bss_seg
= bss_section
;
1935 name
= input_line_pointer
;
1936 c
= get_symbol_end ();
1937 p
= input_line_pointer
;
1941 /* Accept an optional comma after the name. The comma used to be
1942 required, but Irix 5 cc does not generate it. */
1943 if (*input_line_pointer
== ',')
1945 ++input_line_pointer
;
1949 if (*input_line_pointer
== '\n')
1951 as_bad (_("Missing size expression"));
1955 if ((temp
= get_absolute_expression ()) < 0)
1957 as_warn (_("BSS length (%d.) <0! Ignored."), temp
);
1958 ignore_rest_of_line ();
1962 #if defined (TC_MIPS) || defined (TC_ALPHA)
1963 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1964 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1966 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1967 if (temp
<= bfd_get_gp_size (stdoutput
))
1969 bss_seg
= subseg_new (".sbss", 1);
1970 seg_info (bss_seg
)->bss
= 1;
1971 #ifdef BFD_ASSEMBLER
1972 if (! bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1973 as_warn (_("error setting flags for \".sbss\": %s"),
1974 bfd_errmsg (bfd_get_error ()));
1981 /* FIXME. This needs to be machine independent. */
1992 /* FIXME: This needs to be done in a more general fashion. */
1996 record_alignment(bss_seg
, align
);
2003 if (*input_line_pointer
!= ',')
2005 as_bad (_("Expected comma after size"));
2006 ignore_rest_of_line ();
2009 input_line_pointer
++;
2011 if (*input_line_pointer
== '\n')
2013 as_bad (_("Missing alignment"));
2016 align
= get_absolute_expression ();
2019 /* Convert to a power of 2. */
2024 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2027 as_bad (_("Alignment not a power of 2"));
2031 if (align
> max_alignment
)
2033 align
= max_alignment
;
2034 as_warn (_("Alignment too large: %d. assumed."), align
);
2039 as_warn (_("Alignment negative. 0 assumed."));
2041 record_alignment (bss_seg
, align
);
2042 } /* if needs align */
2045 /* Assume some objects may require alignment on some systems. */
2046 #if defined (TC_ALPHA) && ! defined (VMS)
2049 align
= ffs (temp
) - 1;
2050 if (temp
% (1 << align
))
2057 symbolP
= symbol_find_or_make (name
);
2061 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2062 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2063 #ifdef BFD_ASSEMBLER
2064 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2065 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2067 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2070 (S_GET_SEGMENT (symbolP
) == bss_seg
2071 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2075 subseg_set (bss_seg
, 1);
2078 frag_align (align
, 0, 0);
2079 /* detach from old frag */
2080 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2081 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2083 symbol_set_frag (symbolP
, frag_now
);
2084 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
2085 (offsetT
) temp
, (char *) 0);
2088 S_SET_SEGMENT (symbolP
, bss_seg
);
2091 /* The symbol may already have been created with a preceding
2092 ".globl" directive -- be careful not to step on storage class
2093 in that case. Otherwise, set it to static. */
2094 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2096 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2098 #endif /* OBJ_COFF */
2101 S_SET_SIZE (symbolP
, temp
);
2105 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
2106 S_GET_NAME (symbolP
));
2108 subseg_set (current_seg
, current_subseg
);
2110 demand_empty_rest_of_line ();
2111 } /* s_lcomm_internal() */
2114 s_lcomm (needs_align
)
2117 s_lcomm_internal (needs_align
, 0);
2120 void s_lcomm_bytes (needs_align
)
2123 s_lcomm_internal (needs_align
, 1);
2128 int ignore ATTRIBUTE_UNUSED
;
2130 register char *name
;
2134 register symbolS
*symbolP
;
2136 /* we permit ANY defined expression: BSD4.2 demands constants */
2137 name
= input_line_pointer
;
2138 c
= get_symbol_end ();
2139 p
= input_line_pointer
;
2142 if (*input_line_pointer
!= ',')
2145 as_bad (_("Expected comma after name \"%s\""), name
);
2147 ignore_rest_of_line ();
2150 input_line_pointer
++;
2152 if (exp
.X_op
!= O_constant
2153 && exp
.X_op
!= O_register
)
2155 as_bad (_("bad expression"));
2156 ignore_rest_of_line ();
2160 symbolP
= symbol_find_or_make (name
);
2162 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2163 symbolP->sy_desc == 0) out of this test because coff doesn't have
2164 those fields, and I can't see when they'd ever be tripped. I
2165 don't think I understand why they were here so I may have
2166 introduced a bug. As recently as 1.37 didn't have this test
2167 anyway. xoxorich. */
2169 if (S_GET_SEGMENT (symbolP
) == undefined_section
2170 && S_GET_VALUE (symbolP
) == 0)
2172 /* The name might be an undefined .global symbol; be sure to
2173 keep the "external" bit. */
2174 S_SET_SEGMENT (symbolP
,
2175 (exp
.X_op
== O_constant
2178 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2182 as_bad (_("Symbol %s already defined"), name
);
2185 demand_empty_rest_of_line ();
2188 /* Read a line into an sb. */
2194 char quote1
, quote2
, inquote
;
2196 if (input_line_pointer
[-1] == '\n')
2197 bump_line_counters ();
2199 if (input_line_pointer
>= buffer_limit
)
2201 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2202 if (buffer_limit
== 0)
2206 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2207 code needs to be changed. */
2208 if (! flag_m68k_mri
)
2216 #ifdef LEX_IS_STRINGQUOTE
2221 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
2222 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2224 if (inquote
== *input_line_pointer
)
2226 else if (inquote
== '\0')
2228 if (*input_line_pointer
== quote1
)
2230 else if (*input_line_pointer
== quote2
)
2233 sb_add_char (line
, *input_line_pointer
++);
2235 while (input_line_pointer
< buffer_limit
2236 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2238 if (input_line_pointer
[-1] == '\n')
2239 bump_line_counters ();
2240 ++input_line_pointer
;
2245 /* Define a macro. This is an interface to macro.c, which is shared
2246 between gas and gasp. */
2250 int ignore ATTRIBUTE_UNUSED
;
2259 as_where (&file
, &line
);
2262 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
2263 sb_add_char (&s
, *input_line_pointer
++);
2266 if (line_label
!= NULL
)
2267 sb_add_string (&label
, S_GET_NAME (line_label
));
2269 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2271 as_bad_where (file
, line
, "%s", err
);
2274 if (line_label
!= NULL
)
2276 S_SET_SEGMENT (line_label
, undefined_section
);
2277 S_SET_VALUE (line_label
, 0);
2278 symbol_set_frag (line_label
, &zero_address_frag
);
2282 #ifdef NO_PSEUDO_DOT
2286 && hash_find (po_hash
, name
) != NULL
)
2289 && hash_find (po_hash
, name
+ 1) != NULL
))
2290 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2297 /* Handle the .mexit pseudo-op, which immediately exits a macro
2302 int ignore ATTRIBUTE_UNUSED
;
2304 cond_exit_macro (macro_nest
);
2305 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2308 /* Switch in and out of MRI mode. */
2312 int ignore ATTRIBUTE_UNUSED
;
2316 on
= get_absolute_expression ();
2317 old_flag
= flag_mri
;
2333 /* Operator precedence changes in m68k MRI mode, so we need to
2334 update the operator rankings. */
2335 expr_set_precedence ();
2337 #ifdef MRI_MODE_CHANGE
2339 MRI_MODE_CHANGE (on
);
2342 demand_empty_rest_of_line ();
2345 /* Handle changing the location counter. */
2348 do_org (segment
, exp
, fill
)
2353 if (segment
!= now_seg
&& segment
!= absolute_section
)
2354 as_bad (_("invalid segment \"%s\"; segment \"%s\" assumed"),
2355 segment_name (segment
), segment_name (now_seg
));
2357 if (now_seg
== absolute_section
)
2360 as_warn (_("ignoring fill value in absolute section"));
2361 if (exp
->X_op
!= O_constant
)
2363 as_bad (_("only constant offsets supported in absolute section"));
2364 exp
->X_add_number
= 0;
2366 abs_section_offset
= exp
->X_add_number
;
2372 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
->X_add_symbol
,
2373 exp
->X_add_number
* OCTETS_PER_BYTE
, (char *) NULL
);
2380 int ignore ATTRIBUTE_UNUSED
;
2382 register segT segment
;
2384 register long temp_fill
;
2386 #ifdef md_flush_pending_output
2387 md_flush_pending_output ();
2390 /* The m68k MRI assembler has a different meaning for .org. It
2391 means to create an absolute section at a given address. We can't
2392 support that--use a linker script instead. */
2395 as_bad (_("MRI style ORG pseudo-op not supported"));
2396 ignore_rest_of_line ();
2400 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2401 thing as a sub-segment-relative origin. Any absolute origin is
2402 given a warning, then assumed to be segment-relative. Any
2403 segmented origin expression ("foo+42") had better be in the right
2404 segment or the .org is ignored.
2406 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2407 we never know sub-segment sizes when we are reading code. BSD
2408 will crash trying to emit negative numbers of filler bytes in
2409 certain .orgs. We don't crash, but see as-write for that code.
2411 Don't make frag if need_pass_2==1. */
2412 segment
= get_known_segmented_expression (&exp
);
2413 if (*input_line_pointer
== ',')
2415 input_line_pointer
++;
2416 temp_fill
= get_absolute_expression ();
2422 do_org (segment
, &exp
, temp_fill
);
2424 demand_empty_rest_of_line ();
2427 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2428 called by the obj-format routine which handles section changing
2429 when in MRI mode. It will create a new section, and return it. It
2430 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2431 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2432 flags will be set in the section. */
2436 char *type ATTRIBUTE_UNUSED
;
2446 name
= input_line_pointer
;
2447 if (! isdigit ((unsigned char) *name
))
2448 c
= get_symbol_end ();
2453 ++input_line_pointer
;
2455 while (isdigit ((unsigned char) *input_line_pointer
));
2456 c
= *input_line_pointer
;
2457 *input_line_pointer
= '\0';
2460 name
= xstrdup (name
);
2462 *input_line_pointer
= c
;
2464 seg
= subseg_new (name
, 0);
2466 if (*input_line_pointer
== ',')
2470 ++input_line_pointer
;
2471 align
= get_absolute_expression ();
2472 record_alignment (seg
, align
);
2476 if (*input_line_pointer
== ',')
2478 c
= *++input_line_pointer
;
2479 c
= toupper ((unsigned char) c
);
2480 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2483 as_bad (_("unrecognized section type"));
2484 ++input_line_pointer
;
2486 #ifdef BFD_ASSEMBLER
2490 flags
= SEC_NO_FLAGS
;
2492 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2493 else if (*type
== 'D' || *type
== 'M')
2494 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2495 else if (*type
== 'R')
2496 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2497 if (flags
!= SEC_NO_FLAGS
)
2499 if (! bfd_set_section_flags (stdoutput
, seg
, flags
))
2500 as_warn (_("error setting flags for \"%s\": %s"),
2501 bfd_section_name (stdoutput
, seg
),
2502 bfd_errmsg (bfd_get_error ()));
2508 /* Ignore the HP type. */
2509 if (*input_line_pointer
== ',')
2510 input_line_pointer
+= 2;
2512 demand_empty_rest_of_line ();
2514 #else /* ! TC_M68K */
2523 name
= input_line_pointer
;
2524 c
= get_symbol_end ();
2526 name
= xstrdup (name
);
2528 *input_line_pointer
= c
;
2530 seg
= subseg_new (name
, 0);
2532 if (*input_line_pointer
!= ',')
2538 ++input_line_pointer
;
2540 sectype
= input_line_pointer
;
2541 c
= get_symbol_end ();
2542 if (*sectype
== '\0')
2544 else if (strcasecmp (sectype
, "text") == 0)
2546 else if (strcasecmp (sectype
, "data") == 0)
2548 else if (strcasecmp (sectype
, "romdata") == 0)
2551 as_warn (_("unrecognized section type `%s'"), sectype
);
2552 *input_line_pointer
= c
;
2555 if (*input_line_pointer
== ',')
2559 ++input_line_pointer
;
2561 seccmd
= input_line_pointer
;
2562 c
= get_symbol_end ();
2563 if (strcasecmp (seccmd
, "absolute") == 0)
2565 as_bad (_("absolute sections are not supported"));
2566 *input_line_pointer
= c
;
2567 ignore_rest_of_line ();
2570 else if (strcasecmp (seccmd
, "align") == 0)
2574 *input_line_pointer
= c
;
2575 align
= get_absolute_expression ();
2576 record_alignment (seg
, align
);
2580 as_warn (_("unrecognized section command `%s'"), seccmd
);
2581 *input_line_pointer
= c
;
2585 demand_empty_rest_of_line ();
2587 #else /* ! TC_I960 */
2588 /* The MRI assembler seems to use different forms of .sect for
2589 different targets. */
2590 as_bad ("MRI mode not supported for this target");
2591 ignore_rest_of_line ();
2592 #endif /* ! TC_I960 */
2593 #endif /* ! TC_M68K */
2596 /* Handle the .print pseudo-op. */
2600 int ignore ATTRIBUTE_UNUSED
;
2605 s
= demand_copy_C_string (&len
);
2607 demand_empty_rest_of_line ();
2610 /* Handle the .purgem pseudo-op. */
2614 int ignore ATTRIBUTE_UNUSED
;
2616 if (is_it_end_of_statement ())
2618 demand_empty_rest_of_line ();
2628 name
= input_line_pointer
;
2629 c
= get_symbol_end ();
2630 delete_macro (name
);
2631 *input_line_pointer
= c
;
2634 while (*input_line_pointer
++ == ',');
2636 --input_line_pointer
;
2637 demand_empty_rest_of_line ();
2640 /* Handle the .rept pseudo-op. */
2644 int ignore ATTRIBUTE_UNUSED
;
2648 count
= get_absolute_expression ();
2650 do_repeat(count
, "REPT", "ENDR");
2653 /* This function provides a generic repeat block implementation. It allows
2654 different directives to be used as the start/end keys. */
2657 do_repeat (count
, start
, end
)
2666 if (! buffer_and_nest (start
, end
, &one
, get_line_sb
))
2668 as_bad (_("%s without %s"), start
, end
);
2674 sb_add_sb (&many
, &one
);
2678 input_scrub_include_sb (&many
, input_line_pointer
);
2680 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2683 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2684 input buffers to skip. Assumes that conditionals preceding the loop end
2685 are properly nested.
2687 This function makes it easier to implement a premature "break" out of the
2688 loop. The EXTRA arg accounts for other buffers we might have inserted,
2689 such as line substitutions. */
2695 cond_exit_macro (macro_nest
);
2696 while (extra
-- >= 0)
2697 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2700 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2701 this is .equiv, and it is an error if the symbol is already
2708 register char *name
;
2709 register char delim
;
2710 register char *end_name
;
2711 register symbolS
*symbolP
;
2714 * Especial apologies for the random logic:
2715 * this just grew, and could be parsed much more simply!
2718 name
= input_line_pointer
;
2719 delim
= get_symbol_end ();
2720 end_name
= input_line_pointer
;
2724 if (*input_line_pointer
!= ',')
2727 as_bad (_("Expected comma after name \"%s\""), name
);
2729 ignore_rest_of_line ();
2733 input_line_pointer
++;
2736 if (name
[0] == '.' && name
[1] == '\0')
2738 /* Turn '. = mumble' into a .org mumble */
2739 register segT segment
;
2742 segment
= get_known_segmented_expression (&exp
);
2745 do_org (segment
, &exp
, 0);
2751 if ((symbolP
= symbol_find (name
)) == NULL
2752 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2755 /* When doing symbol listings, play games with dummy fragments living
2756 outside the normal fragment chain to record the file and line info
2758 if (listing
& LISTING_SYMBOLS
)
2760 extern struct list_info_struct
*listing_tail
;
2761 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof(fragS
));
2762 memset (dummy_frag
, 0, sizeof(fragS
));
2763 dummy_frag
->fr_type
= rs_fill
;
2764 dummy_frag
->line
= listing_tail
;
2765 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2766 dummy_frag
->fr_symbol
= symbolP
;
2770 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2773 /* "set" symbols are local unless otherwise specified. */
2774 SF_SET_LOCAL (symbolP
);
2775 #endif /* OBJ_COFF */
2777 } /* make a new symbol */
2779 symbol_table_insert (symbolP
);
2784 && S_IS_DEFINED (symbolP
)
2785 && S_GET_SEGMENT (symbolP
) != reg_section
)
2786 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
2788 pseudo_set (symbolP
);
2789 demand_empty_rest_of_line ();
2803 #ifdef md_flush_pending_output
2804 md_flush_pending_output ();
2808 stop
= mri_comment_field (&stopc
);
2810 /* In m68k MRI mode, we need to align to a word boundary, unless
2812 if (flag_m68k_mri
&& mult
> 1)
2814 if (now_seg
== absolute_section
)
2816 abs_section_offset
+= abs_section_offset
& 1;
2817 if (line_label
!= NULL
)
2818 S_SET_VALUE (line_label
, abs_section_offset
);
2820 else if (mri_common_symbol
!= NULL
)
2824 val
= S_GET_VALUE (mri_common_symbol
);
2827 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2828 if (line_label
!= NULL
)
2830 expressionS
*symexp
;
2832 symexp
= symbol_get_value_expression (line_label
);
2833 know (symexp
->X_op
== O_symbol
);
2834 know (symexp
->X_add_symbol
== mri_common_symbol
);
2835 symexp
->X_add_number
+= 1;
2841 do_align (1, (char *) NULL
, 0, 0);
2842 if (line_label
!= NULL
)
2844 symbol_set_frag (line_label
, frag_now
);
2845 S_SET_VALUE (line_label
, frag_now_fix ());
2855 if (*input_line_pointer
== ',')
2857 ++input_line_pointer
;
2862 val
.X_op
= O_constant
;
2863 val
.X_add_number
= 0;
2866 if (val
.X_op
!= O_constant
2867 || val
.X_add_number
< - 0x80
2868 || val
.X_add_number
> 0xff
2869 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2871 if (exp
.X_op
!= O_constant
)
2872 as_bad (_("Unsupported variable size or fill value"));
2879 bytes
= mult
* exp
.X_add_number
;
2880 for (i
= 0; i
< exp
.X_add_number
; i
++)
2881 emit_expr (&val
, mult
);
2886 if (exp
.X_op
== O_constant
)
2890 repeat
= exp
.X_add_number
;
2897 as_warn (_(".space repeat count is zero, ignored"));
2898 else if (repeat
< 0)
2899 as_warn (_(".space repeat count is negative, ignored"));
2903 /* If we are in the absolute section, just bump the offset. */
2904 if (now_seg
== absolute_section
)
2906 abs_section_offset
+= repeat
;
2910 /* If we are secretly in an MRI common section, then
2911 creating space just increases the size of the common
2913 if (mri_common_symbol
!= NULL
)
2915 S_SET_VALUE (mri_common_symbol
,
2916 S_GET_VALUE (mri_common_symbol
) + repeat
);
2921 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2922 (offsetT
) repeat
, (char *) 0);
2926 if (now_seg
== absolute_section
)
2928 as_bad (_("space allocation too complex in absolute section"));
2929 subseg_set (text_section
, 0);
2931 if (mri_common_symbol
!= NULL
)
2933 as_bad (_("space allocation too complex in common section"));
2934 mri_common_symbol
= NULL
;
2937 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2938 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2942 *p
= val
.X_add_number
;
2947 /* In MRI mode, after an odd number of bytes, we must align to an
2948 even word boundary, unless the next instruction is a dc.b, ds.b
2950 if (flag_mri
&& (bytes
& 1) != 0)
2951 mri_pending_align
= 1;
2953 demand_empty_rest_of_line ();
2956 mri_comment_end (stop
, stopc
);
2959 /* This is like s_space, but the value is a floating point number with
2960 the given precision. This is for the MRI dcb.s pseudo-op and
2964 s_float_space (float_type
)
2969 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2974 stop
= mri_comment_field (&stopc
);
2976 count
= get_absolute_expression ();
2979 if (*input_line_pointer
!= ',')
2981 as_bad (_("missing value"));
2982 ignore_rest_of_line ();
2984 mri_comment_end (stop
, stopc
);
2988 ++input_line_pointer
;
2992 /* Skip any 0{letter} that may be present. Don't even check if the
2993 * letter is legal. */
2994 if (input_line_pointer
[0] == '0'
2995 && isalpha ((unsigned char) input_line_pointer
[1]))
2996 input_line_pointer
+= 2;
2998 /* Accept :xxxx, where the x's are hex digits, for a floating point
2999 with the exact digits specified. */
3000 if (input_line_pointer
[0] == ':')
3002 flen
= hex_float (float_type
, temp
);
3005 ignore_rest_of_line ();
3007 mri_comment_end (stop
, stopc
);
3015 err
= md_atof (float_type
, temp
, &flen
);
3016 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3020 as_bad (_("Bad floating literal: %s"), err
);
3021 ignore_rest_of_line ();
3023 mri_comment_end (stop
, stopc
);
3028 while (--count
>= 0)
3032 p
= frag_more (flen
);
3033 memcpy (p
, temp
, (unsigned int) flen
);
3036 demand_empty_rest_of_line ();
3039 mri_comment_end (stop
, stopc
);
3042 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3046 int ignore ATTRIBUTE_UNUSED
;
3052 stop
= mri_comment_field (&stopc
);
3053 abs_section_offset
= get_absolute_expression ();
3054 subseg_set (absolute_section
, 0);
3055 demand_empty_rest_of_line ();
3057 mri_comment_end (stop
, stopc
);
3062 int ignore ATTRIBUTE_UNUSED
;
3066 temp
= get_absolute_expression ();
3067 subseg_set (text_section
, (subsegT
) temp
);
3068 demand_empty_rest_of_line ();
3070 const_flag
&= ~IN_DEFAULT_SECTION
;
3076 demand_empty_rest_of_line ()
3079 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3081 input_line_pointer
++;
3085 ignore_rest_of_line ();
3087 /* Return having already swallowed end-of-line. */
3088 } /* Return pointing just after end-of-line. */
3091 ignore_rest_of_line () /* For suspect lines: gives warning. */
3093 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3095 if (isprint ((unsigned char) *input_line_pointer
))
3096 as_bad (_("Rest of line ignored. First ignored character is `%c'."),
3097 *input_line_pointer
);
3099 as_bad (_("Rest of line ignored. First ignored character valued 0x%x."),
3100 *input_line_pointer
);
3101 while (input_line_pointer
< buffer_limit
3102 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3104 input_line_pointer
++;
3107 input_line_pointer
++; /* Return pointing just after end-of-line. */
3108 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3112 discard_rest_of_line ()
3114 while (input_line_pointer
< buffer_limit
3115 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3117 input_line_pointer
++;
3119 input_line_pointer
++; /* Return pointing just after end-of-line. */
3120 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3126 * In: Pointer to a symbol.
3127 * Input_line_pointer->expression.
3129 * Out: Input_line_pointer->just after any whitespace after expression.
3130 * Tried to set symbol to value of expression.
3131 * Will change symbols type, value, and frag;
3134 pseudo_set (symbolP
)
3138 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3140 #endif /* OBJ_AOUT or OBJ_BOUT */
3142 know (symbolP
); /* NULL pointer is logic error. */
3143 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3144 ext
= S_IS_EXTERNAL (symbolP
);
3145 #endif /* OBJ_AOUT or OBJ_BOUT */
3147 (void) expression (&exp
);
3149 if (exp
.X_op
== O_illegal
)
3150 as_bad (_("illegal expression; zero assumed"));
3151 else if (exp
.X_op
== O_absent
)
3152 as_bad (_("missing expression; zero assumed"));
3153 else if (exp
.X_op
== O_big
)
3155 if (exp
.X_add_number
> 0)
3156 as_bad (_("bignum invalid; zero assumed"));
3158 as_bad (_("floating point number invalid; zero assumed"));
3160 else if (exp
.X_op
== O_subtract
3161 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3162 == S_GET_SEGMENT (exp
.X_op_symbol
))
3163 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3164 && (symbol_get_frag (exp
.X_add_symbol
)
3165 == symbol_get_frag (exp
.X_op_symbol
)))
3167 exp
.X_op
= O_constant
;
3168 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3169 - S_GET_VALUE (exp
.X_op_symbol
));
3177 exp
.X_add_number
= 0;
3180 S_SET_SEGMENT (symbolP
, absolute_section
);
3181 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3183 S_SET_EXTERNAL (symbolP
);
3185 S_CLEAR_EXTERNAL (symbolP
);
3186 #endif /* OBJ_AOUT or OBJ_BOUT */
3187 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3188 if (exp
.X_op
!= O_constant
)
3189 symbol_set_frag (symbolP
, &zero_address_frag
);
3193 S_SET_SEGMENT (symbolP
, reg_section
);
3194 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3195 symbol_set_frag (symbolP
, &zero_address_frag
);
3199 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3200 || exp
.X_add_number
!= 0)
3201 symbol_set_value_expression (symbolP
, &exp
);
3202 else if (symbol_section_p (symbolP
))
3203 as_bad ("invalid attempt to set value of section symbol");
3206 symbolS
*s
= exp
.X_add_symbol
;
3208 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3209 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3211 S_SET_EXTERNAL (symbolP
);
3213 S_CLEAR_EXTERNAL (symbolP
);
3214 #endif /* OBJ_AOUT or OBJ_BOUT */
3215 S_SET_VALUE (symbolP
,
3216 exp
.X_add_number
+ S_GET_VALUE (s
));
3217 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3218 copy_symbol_attributes (symbolP
, s
);
3223 /* The value is some complex expression.
3224 FIXME: Should we set the segment to anything? */
3225 symbol_set_value_expression (symbolP
, &exp
);
3233 * CONStruct more frag of .bytes, or .words etc.
3234 * Should need_pass_2 be 1 then emit no frag(s).
3235 * This understands EXPRESSIONS.
3239 * This has a split personality. We use expression() to read the
3240 * value. We can detect if the value won't fit in a byte or word.
3241 * But we can't detect if expression() discarded significant digits
3242 * in the case of a long. Not worth the crocks required to fix it.
3245 /* Select a parser for cons expressions. */
3247 /* Some targets need to parse the expression in various fancy ways.
3248 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3249 (for example, the HPPA does this). Otherwise, you can define
3250 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3251 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3252 are defined, which is the normal case, then only simple expressions
3256 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3258 #ifndef TC_PARSE_CONS_EXPRESSION
3259 #ifdef BITFIELD_CONS_EXPRESSIONS
3260 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3262 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3264 #ifdef REPEAT_CONS_EXPRESSIONS
3265 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3267 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3270 /* If we haven't gotten one yet, just call expression. */
3271 #ifndef TC_PARSE_CONS_EXPRESSION
3272 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3276 /* worker to do .byte etc statements */
3277 /* clobbers input_line_pointer, checks */
3280 cons_worker (nbytes
, rva
)
3281 register int nbytes
; /* 1=.byte, 2=.word, 4=.long */
3289 #ifdef md_flush_pending_output
3290 md_flush_pending_output ();
3294 stop
= mri_comment_field (&stopc
);
3296 if (is_it_end_of_statement ())
3298 demand_empty_rest_of_line ();
3300 mri_comment_end (stop
, stopc
);
3304 #ifdef md_cons_align
3305 md_cons_align (nbytes
);
3312 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3314 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3318 if (exp
.X_op
== O_symbol
)
3319 exp
.X_op
= O_symbol_rva
;
3321 as_fatal (_("rva without symbol"));
3323 emit_expr (&exp
, (unsigned int) nbytes
);
3326 while (*input_line_pointer
++ == ',');
3328 /* In MRI mode, after an odd number of bytes, we must align to an
3329 even word boundary, unless the next instruction is a dc.b, ds.b
3331 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3332 mri_pending_align
= 1;
3334 input_line_pointer
--; /* Put terminator back into stream. */
3336 demand_empty_rest_of_line ();
3339 mri_comment_end (stop
, stopc
);
3347 cons_worker (size
, 0);
3354 cons_worker (size
, 1);
3357 /* Put the contents of expression EXP into the object file using
3358 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3361 emit_expr (exp
, nbytes
)
3363 unsigned int nbytes
;
3367 valueT extra_digit
= 0;
3369 /* Don't do anything if we are going to make another pass. */
3375 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3376 appear as a four byte positive constant in the .line section,
3377 followed by a 2 byte 0xffff. Look for that case here. */
3379 static int dwarf_line
= -1;
3381 if (strcmp (segment_name (now_seg
), ".line") != 0)
3383 else if (dwarf_line
>= 0
3385 && exp
->X_op
== O_constant
3386 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3387 listing_source_line ((unsigned int) dwarf_line
);
3388 else if (nbytes
== 4
3389 && exp
->X_op
== O_constant
3390 && exp
->X_add_number
>= 0)
3391 dwarf_line
= exp
->X_add_number
;
3396 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3397 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3398 AT_sibling (0x12) followed by a four byte address of the sibling
3399 followed by a 2 byte AT_name (0x38) followed by the name of the
3400 file. We look for that case here. */
3402 static int dwarf_file
= 0;
3404 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3406 else if (dwarf_file
== 0
3408 && exp
->X_op
== O_constant
3409 && exp
->X_add_number
== 0x11)
3411 else if (dwarf_file
== 1
3413 && exp
->X_op
== O_constant
3414 && exp
->X_add_number
== 0x12)
3416 else if (dwarf_file
== 2
3419 else if (dwarf_file
== 3
3421 && exp
->X_op
== O_constant
3422 && exp
->X_add_number
== 0x38)
3427 /* The variable dwarf_file_string tells stringer that the string
3428 may be the name of the source file. */
3429 if (dwarf_file
== 4)
3430 dwarf_file_string
= 1;
3432 dwarf_file_string
= 0;
3437 if (check_eh_frame (exp
, &nbytes
))
3442 /* Allow `.word 0' in the absolute section. */
3443 if (now_seg
== absolute_section
)
3445 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3446 as_bad (_("attempt to store value in absolute section"));
3447 abs_section_offset
+= nbytes
;
3451 /* Handle a negative bignum. */
3453 && exp
->X_add_number
== 0
3454 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3455 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3458 unsigned long carry
;
3460 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3462 /* Negate the bignum: one's complement each digit and add 1. */
3464 for (i
= 0; i
< exp
->X_add_number
; i
++)
3468 next
= (((~ (generic_bignum
[i
] & LITTLENUM_MASK
))
3471 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3472 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3475 /* We can ignore any carry out, because it will be handled by
3476 extra_digit if it is needed. */
3478 extra_digit
= (valueT
) -1;
3482 if (op
== O_absent
|| op
== O_illegal
)
3484 as_warn (_("zero assumed for missing expression"));
3485 exp
->X_add_number
= 0;
3488 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3490 as_bad (_("floating point number invalid; zero assumed"));
3491 exp
->X_add_number
= 0;
3494 else if (op
== O_register
)
3496 as_warn (_("register value used as expression"));
3500 p
= frag_more ((int) nbytes
);
3502 #ifndef WORKING_DOT_WORD
3503 /* If we have the difference of two symbols in a word, save it on
3504 the broken_words list. See the code in write.c. */
3505 if (op
== O_subtract
&& nbytes
== 2)
3507 struct broken_word
*x
;
3509 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3510 x
->next_broken_word
= broken_words
;
3513 x
->subseg
= now_subseg
;
3515 x
->word_goes_here
= p
;
3517 x
->add
= exp
->X_add_symbol
;
3518 x
->sub
= exp
->X_op_symbol
;
3519 x
->addnum
= exp
->X_add_number
;
3526 /* If we have an integer, but the number of bytes is too large to
3527 pass to md_number_to_chars, handle it as a bignum. */
3528 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3533 if (! exp
->X_unsigned
&& exp
->X_add_number
< 0)
3534 extra_digit
= (valueT
) -1;
3535 val
= (valueT
) exp
->X_add_number
;
3539 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3540 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3544 op
= exp
->X_op
= O_big
;
3545 exp
->X_add_number
= gencnt
;
3548 if (op
== O_constant
)
3550 register valueT get
;
3551 register valueT use
;
3552 register valueT mask
;
3554 register valueT unmask
;
3556 /* JF << of >= number of bits in the object is undefined. In
3557 particular SPARC (Sun 4) has problems */
3558 if (nbytes
>= sizeof (valueT
))
3561 if (nbytes
> sizeof (valueT
))
3564 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3568 /* Don't store these bits. */
3569 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3570 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3573 unmask
= ~mask
; /* Do store these bits. */
3576 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3577 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3580 get
= exp
->X_add_number
;
3582 if ((get
& mask
) != 0
3583 && ((get
& mask
) != mask
3584 || (get
& hibit
) == 0))
3585 { /* Leading bits contain both 0s & 1s. */
3586 as_warn (_("Value 0x%lx truncated to 0x%lx."),
3587 (unsigned long) get
, (unsigned long) use
);
3589 /* put bytes in right order. */
3590 md_number_to_chars (p
, use
, (int) nbytes
);
3592 else if (op
== O_big
)
3595 LITTLENUM_TYPE
*nums
;
3597 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3599 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3602 as_warn (_("Bignum truncated to %d bytes"), nbytes
);
3606 if (target_big_endian
)
3608 while (nbytes
> size
)
3610 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3611 nbytes
-= CHARS_PER_LITTLENUM
;
3612 p
+= CHARS_PER_LITTLENUM
;
3615 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3619 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3620 size
-= CHARS_PER_LITTLENUM
;
3621 p
+= CHARS_PER_LITTLENUM
;
3626 nums
= generic_bignum
;
3629 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3631 size
-= CHARS_PER_LITTLENUM
;
3632 p
+= CHARS_PER_LITTLENUM
;
3633 nbytes
-= CHARS_PER_LITTLENUM
;
3638 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3639 nbytes
-= CHARS_PER_LITTLENUM
;
3640 p
+= CHARS_PER_LITTLENUM
;
3646 memset (p
, 0, nbytes
);
3648 /* Now we need to generate a fixS to record the symbol value.
3649 This is easy for BFD. For other targets it can be more
3650 complex. For very complex cases (currently, the HPPA and
3651 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3652 want. For simpler cases, you can define TC_CONS_RELOC to be
3653 the name of the reloc code that should be stored in the fixS.
3654 If neither is defined, the code uses NO_RELOC if it is
3655 defined, and otherwise uses 0. */
3657 #ifdef BFD_ASSEMBLER
3658 #ifdef TC_CONS_FIX_NEW
3659 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3662 bfd_reloc_code_real_type r
;
3679 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3683 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3688 #ifdef TC_CONS_FIX_NEW
3689 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3691 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3692 it is defined, otherwise use NO_RELOC if it is defined,
3694 #ifndef TC_CONS_RELOC
3696 #define TC_CONS_RELOC NO_RELOC
3698 #define TC_CONS_RELOC 0
3701 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3703 #endif /* TC_CONS_FIX_NEW */
3704 #endif /* BFD_ASSEMBLER */
3708 #ifdef BITFIELD_CONS_EXPRESSIONS
3710 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3711 w:x,y:z, where w and y are bitwidths and x and y are values. They
3712 then pack them all together. We do a little better in that we allow
3713 them in words, longs, etc. and we'll pack them in target byte order
3716 The rules are: pack least significat bit first, if a field doesn't
3717 entirely fit, put it in the next unit. Overflowing the bitfield is
3718 explicitly *not* even a warning. The bitwidth should be considered
3721 To use this function the tc-XXX.h file should define
3722 BITFIELD_CONS_EXPRESSIONS. */
3725 parse_bitfield_cons (exp
, nbytes
)
3727 unsigned int nbytes
;
3729 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3730 char *hold
= input_line_pointer
;
3732 (void) expression (exp
);
3734 if (*input_line_pointer
== ':')
3740 unsigned long width
;
3742 if (*input_line_pointer
!= ':')
3744 input_line_pointer
= hold
;
3746 } /* next piece is not a bitfield */
3748 /* In the general case, we can't allow
3749 full expressions with symbol
3750 differences and such. The relocation
3751 entries for symbols not defined in this
3752 assembly would require arbitrary field
3753 widths, positions, and masks which most
3754 of our current object formats don't
3757 In the specific case where a symbol
3758 *is* defined in this assembly, we
3759 *could* build fixups and track it, but
3760 this could lead to confusion for the
3761 backends. I'm lazy. I'll take any
3762 SEG_ABSOLUTE. I think that means that
3763 you can use a previous .set or
3764 .equ type symbol. xoxorich. */
3766 if (exp
->X_op
== O_absent
)
3768 as_warn (_("using a bit field width of zero"));
3769 exp
->X_add_number
= 0;
3770 exp
->X_op
= O_constant
;
3771 } /* implied zero width bitfield */
3773 if (exp
->X_op
!= O_constant
)
3775 *input_line_pointer
= '\0';
3776 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3777 *input_line_pointer
= ':';
3778 demand_empty_rest_of_line ();
3782 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3784 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3785 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3786 width
= BITS_PER_CHAR
* nbytes
;
3789 if (width
> bits_available
)
3791 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3792 input_line_pointer
= hold
;
3793 exp
->X_add_number
= value
;
3797 hold
= ++input_line_pointer
; /* skip ':' */
3799 (void) expression (exp
);
3800 if (exp
->X_op
!= O_constant
)
3802 char cache
= *input_line_pointer
;
3804 *input_line_pointer
= '\0';
3805 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3806 *input_line_pointer
= cache
;
3807 demand_empty_rest_of_line ();
3811 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3812 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3814 if ((bits_available
-= width
) == 0
3815 || is_it_end_of_statement ()
3816 || *input_line_pointer
!= ',')
3819 } /* all the bitfields we're gonna get */
3821 hold
= ++input_line_pointer
;
3822 (void) expression (exp
);
3823 } /* forever loop */
3825 exp
->X_add_number
= value
;
3826 exp
->X_op
= O_constant
;
3827 exp
->X_unsigned
= 1;
3828 } /* if looks like a bitfield */
3829 } /* parse_bitfield_cons() */
3831 #endif /* BITFIELD_CONS_EXPRESSIONS */
3833 /* 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
++;
3898 #ifdef REPEAT_CONS_EXPRESSIONS
3900 /* Parse a repeat expression for cons. This is used by the MIPS
3901 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3902 object file COUNT times.
3904 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3907 parse_repeat_cons (exp
, nbytes
)
3909 unsigned int nbytes
;
3916 if (*input_line_pointer
!= ':')
3918 /* No repeat count. */
3922 ++input_line_pointer
;
3923 expression (&count
);
3924 if (count
.X_op
!= O_constant
3925 || count
.X_add_number
<= 0)
3927 as_warn (_("Unresolvable or nonpositive repeat count; using 1"));
3931 /* The cons function is going to output this expression once. So we
3932 output it count - 1 times. */
3933 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3934 emit_expr (exp
, nbytes
);
3937 #endif /* REPEAT_CONS_EXPRESSIONS */
3939 /* Parse a floating point number represented as a hex constant. This
3940 permits users to specify the exact bits they want in the floating
3944 hex_float (float_type
, bytes
)
3978 as_bad (_("Unknown floating type type '%c'"), float_type
);
3982 /* It would be nice if we could go through expression to parse the
3983 hex constant, but if we get a bignum it's a pain to sort it into
3984 the buffer correctly. */
3986 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
3990 /* The MRI assembler accepts arbitrary underscores strewn about
3991 through the hex constant, so we ignore them as well. */
3992 if (*input_line_pointer
== '_')
3994 ++input_line_pointer
;
4000 as_warn (_("Floating point constant too large"));
4003 d
= hex_value (*input_line_pointer
) << 4;
4004 ++input_line_pointer
;
4005 while (*input_line_pointer
== '_')
4006 ++input_line_pointer
;
4007 if (hex_p (*input_line_pointer
))
4009 d
+= hex_value (*input_line_pointer
);
4010 ++input_line_pointer
;
4012 if (target_big_endian
)
4015 bytes
[length
- i
- 1] = d
;
4021 if (target_big_endian
)
4022 memset (bytes
+ i
, 0, length
- i
);
4024 memset (bytes
, 0, length
- i
);
4033 * CONStruct some more frag chars of .floats .ffloats etc.
4034 * Makes 0 or more new frags.
4035 * If need_pass_2 == 1, no frags are emitted.
4036 * This understands only floating literals, not expressions. Sorry.
4038 * A floating constant is defined by atof_generic(), except it is preceded
4039 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4040 * reading, I decided to be incompatible. This always tries to give you
4041 * rounded bits to the precision of the pseudo-op. Former AS did premature
4042 * truncatation, restored noisy bits instead of trailing 0s AND gave you
4043 * a choice of 2 flavours of noise according to which of 2 floating-point
4044 * scanners you directed AS to use.
4046 * In: input_line_pointer->whitespace before, or '0' of flonum.
4051 float_cons (float_type
)
4052 /* Clobbers input_line-pointer, checks end-of-line. */
4053 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4056 int length
; /* Number of chars in an object. */
4057 register char *err
; /* Error from scanning floating literal. */
4058 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4060 if (is_it_end_of_statement ())
4062 demand_empty_rest_of_line ();
4066 #ifdef md_flush_pending_output
4067 md_flush_pending_output ();
4072 /* input_line_pointer->1st char of a flonum (we hope!). */
4075 /* Skip any 0{letter} that may be present. Don't even check if the
4076 * letter is legal. Someone may invent a "z" format and this routine
4077 * has no use for such information. Lusers beware: you get
4078 * diagnostics if your input is ill-conditioned.
4080 if (input_line_pointer
[0] == '0'
4081 && isalpha ((unsigned char) input_line_pointer
[1]))
4082 input_line_pointer
+= 2;
4084 /* Accept :xxxx, where the x's are hex digits, for a floating
4085 point with the exact digits specified. */
4086 if (input_line_pointer
[0] == ':')
4088 ++input_line_pointer
;
4089 length
= hex_float (float_type
, temp
);
4092 ignore_rest_of_line ();
4098 err
= md_atof (float_type
, temp
, &length
);
4099 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4103 as_bad (_("Bad floating literal: %s"), err
);
4104 ignore_rest_of_line ();
4115 #ifdef REPEAT_CONS_EXPRESSIONS
4116 if (*input_line_pointer
== ':')
4118 expressionS count_exp
;
4120 ++input_line_pointer
;
4121 expression (&count_exp
);
4122 if (count_exp
.X_op
!= O_constant
4123 || count_exp
.X_add_number
<= 0)
4125 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4128 count
= count_exp
.X_add_number
;
4132 while (--count
>= 0)
4134 p
= frag_more (length
);
4135 memcpy (p
, temp
, (unsigned int) length
);
4140 while (*input_line_pointer
++ == ',');
4142 --input_line_pointer
; /* Put terminator back into stream. */
4143 demand_empty_rest_of_line ();
4144 } /* float_cons() */
4146 /* Return the size of a LEB128 value */
4149 sizeof_sleb128 (value
)
4152 register int size
= 0;
4153 register unsigned byte
;
4157 byte
= (value
& 0x7f);
4158 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4159 Fortunately, we can structure things so that the extra work reduces
4160 to a noop on systems that do things "properly". */
4161 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4164 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4165 || ((value
== -1) && ((byte
& 0x40) != 0))));
4171 sizeof_uleb128 (value
)
4174 register int size
= 0;
4175 register unsigned byte
;
4179 byte
= (value
& 0x7f);
4189 sizeof_leb128 (value
, sign
)
4194 return sizeof_sleb128 ((offsetT
) value
);
4196 return sizeof_uleb128 (value
);
4199 /* Output a LEB128 value. */
4202 output_sleb128 (p
, value
)
4206 register char *orig
= p
;
4211 unsigned byte
= (value
& 0x7f);
4213 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4214 Fortunately, we can structure things so that the extra work reduces
4215 to a noop on systems that do things "properly". */
4216 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4218 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4219 || ((value
== -1) && ((byte
& 0x40) != 0))));
4231 output_uleb128 (p
, value
)
4239 unsigned byte
= (value
& 0x7f);
4242 /* More bytes to follow. */
4253 output_leb128 (p
, value
, sign
)
4259 return output_sleb128 (p
, (offsetT
) value
);
4261 return output_uleb128 (p
, value
);
4264 /* Do the same for bignums. We combine sizeof with output here in that
4265 we don't output for NULL values of P. It isn't really as critical as
4266 for "normal" values that this be streamlined. */
4269 output_big_sleb128 (p
, bignum
, size
)
4271 LITTLENUM_TYPE
*bignum
;
4279 /* Strip leading sign extensions off the bignum. */
4280 while (size
> 0 && bignum
[size
-1] == (LITTLENUM_TYPE
)-1)
4285 if (loaded
< 7 && size
> 0)
4287 val
|= (*bignum
<< loaded
);
4288 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4299 if ((val
== 0 && (byte
& 0x40) == 0)
4300 || (~(val
| ~(((valueT
)1 << loaded
) - 1)) == 0
4301 && (byte
& 0x40) != 0))
4309 while (byte
& 0x80);
4315 output_big_uleb128 (p
, bignum
, size
)
4317 LITTLENUM_TYPE
*bignum
;
4325 /* Strip leading zeros off the bignum. */
4326 /* XXX: Is this needed? */
4327 while (size
> 0 && bignum
[size
-1] == 0)
4332 if (loaded
< 7 && size
> 0)
4334 val
|= (*bignum
<< loaded
);
4335 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4344 if (size
> 0 || val
)
4351 while (byte
& 0x80);
4357 output_big_leb128 (p
, bignum
, size
, sign
)
4359 LITTLENUM_TYPE
*bignum
;
4363 return output_big_sleb128 (p
, bignum
, size
);
4365 return output_big_uleb128 (p
, bignum
, size
);
4368 /* Generate the appropriate fragments for a given expression to emit a
4372 emit_leb128_expr(exp
, sign
)
4376 operatorT op
= exp
->X_op
;
4378 if (op
== O_absent
|| op
== O_illegal
)
4380 as_warn (_("zero assumed for missing expression"));
4381 exp
->X_add_number
= 0;
4384 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4386 as_bad (_("floating point number invalid; zero assumed"));
4387 exp
->X_add_number
= 0;
4390 else if (op
== O_register
)
4392 as_warn (_("register value used as expression"));
4396 if (op
== O_constant
)
4398 /* If we've got a constant, emit the thing directly right now. */
4400 valueT value
= exp
->X_add_number
;
4404 size
= sizeof_leb128 (value
, sign
);
4405 p
= frag_more (size
);
4406 output_leb128 (p
, value
, sign
);
4408 else if (op
== O_big
)
4410 /* O_big is a different sort of constant. */
4415 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4416 p
= frag_more (size
);
4417 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4421 /* Otherwise, we have to create a variable sized fragment and
4422 resolve things later. */
4424 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
)0), 0, sign
,
4425 make_expr_symbol (exp
), 0, (char *) NULL
);
4429 /* Parse the .sleb128 and .uleb128 pseudos. */
4439 emit_leb128_expr (&exp
, sign
);
4440 } while (*input_line_pointer
++ == ',');
4442 input_line_pointer
--;
4443 demand_empty_rest_of_line ();
4449 * We read 0 or more ',' separated, double-quoted strings.
4451 * Caller should have checked need_pass_2 is FALSE because we don't check it.
4456 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4457 /* Checks end-of-line. */
4458 register int append_zero
; /* 0: don't append '\0', else 1 */
4460 register unsigned int c
;
4463 #ifdef md_flush_pending_output
4464 md_flush_pending_output ();
4468 * The following awkward logic is to parse ZERO or more strings,
4469 * comma separated. Recall a string expression includes spaces
4470 * before the opening '\"' and spaces after the closing '\"'.
4471 * We fake a leading ',' if there is (supposed to be)
4472 * a 1st, expression. We keep demanding expressions for each
4475 if (is_it_end_of_statement ())
4477 c
= 0; /* Skip loop. */
4478 ++input_line_pointer
; /* Compensate for end of loop. */
4482 c
= ','; /* Do loop. */
4484 while (c
== ',' || c
== '<' || c
== '"')
4487 switch (*input_line_pointer
)
4490 ++input_line_pointer
; /*->1st char of string. */
4491 start
= input_line_pointer
;
4492 while (is_a_char (c
= next_char_of_string ()))
4494 FRAG_APPEND_1_CHAR (c
);
4498 FRAG_APPEND_1_CHAR (0);
4500 know (input_line_pointer
[-1] == '\"');
4504 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4505 will emit .string with a filename in the .debug section
4506 after a sequence of constants. See the comment in
4507 emit_expr for the sequence. emit_expr will set
4508 dwarf_file_string to non-zero if this string might be a
4509 source file name. */
4510 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4511 dwarf_file_string
= 0;
4512 else if (dwarf_file_string
)
4514 c
= input_line_pointer
[-1];
4515 input_line_pointer
[-1] = '\0';
4516 listing_source_file (start
);
4517 input_line_pointer
[-1] = c
;
4524 input_line_pointer
++;
4525 c
= get_single_number ();
4526 FRAG_APPEND_1_CHAR (c
);
4527 if (*input_line_pointer
!= '>')
4529 as_bad (_("Expected <nn>"));
4531 input_line_pointer
++;
4534 input_line_pointer
++;
4538 c
= *input_line_pointer
;
4541 demand_empty_rest_of_line ();
4544 /* FIXME-SOMEDAY: I had trouble here on characters with the
4545 high bits set. We'll probably also have trouble with
4546 multibyte chars, wide chars, etc. Also be careful about
4547 returning values bigger than 1 byte. xoxorich. */
4550 next_char_of_string ()
4552 register unsigned int c
;
4554 c
= *input_line_pointer
++ & CHAR_MASK
;
4562 as_warn (_("Unterminated string: Newline inserted."));
4563 bump_line_counters ();
4566 #ifndef NO_STRING_ESCAPES
4568 switch (c
= *input_line_pointer
++)
4596 break; /* As itself. */
4612 for (i
= 0, number
= 0; isdigit (c
) && i
< 3; c
= *input_line_pointer
++, i
++)
4614 number
= number
* 8 + c
- '0';
4618 --input_line_pointer
;
4627 c
= *input_line_pointer
++;
4628 while (isxdigit (c
))
4631 number
= number
* 16 + c
- '0';
4632 else if (isupper (c
))
4633 number
= number
* 16 + c
- 'A' + 10;
4635 number
= number
* 16 + c
- 'a' + 10;
4636 c
= *input_line_pointer
++;
4639 --input_line_pointer
;
4644 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4645 as_warn (_("Unterminated string: Newline inserted."));
4647 bump_line_counters ();
4652 #ifdef ONLY_STANDARD_ESCAPES
4653 as_bad (_("Bad escaped character in string, '?' assumed"));
4655 #endif /* ONLY_STANDARD_ESCAPES */
4658 } /* switch on escaped char */
4660 #endif /* ! defined (NO_STRING_ESCAPES) */
4664 } /* switch on char */
4666 } /* next_char_of_string() */
4669 get_segmented_expression (expP
)
4670 register expressionS
*expP
;
4672 register segT retval
;
4674 retval
= expression (expP
);
4675 if (expP
->X_op
== O_illegal
4676 || expP
->X_op
== O_absent
4677 || expP
->X_op
== O_big
)
4679 as_bad (_("expected address expression; zero assumed"));
4680 expP
->X_op
= O_constant
;
4681 expP
->X_add_number
= 0;
4682 retval
= absolute_section
;
4688 get_known_segmented_expression (expP
)
4689 register expressionS
*expP
;
4691 register segT retval
;
4693 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4695 /* There is no easy way to extract the undefined symbol from the
4697 if (expP
->X_add_symbol
!= NULL
4698 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4699 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4700 S_GET_NAME (expP
->X_add_symbol
));
4702 as_warn (_("some symbol undefined; zero assumed"));
4703 retval
= absolute_section
;
4704 expP
->X_op
= O_constant
;
4705 expP
->X_add_number
= 0;
4707 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4709 } /* get_known_segmented_expression() */
4712 get_absolute_expression ()
4717 if (exp
.X_op
!= O_constant
)
4719 if (exp
.X_op
!= O_absent
)
4720 as_bad (_("bad or irreducible absolute expression; zero assumed"));
4721 exp
.X_add_number
= 0;
4723 return exp
.X_add_number
;
4726 char /* return terminator */
4727 get_absolute_expression_and_terminator (val_pointer
)
4728 long *val_pointer
; /* return value of expression */
4730 /* FIXME: val_pointer should probably be offsetT *. */
4731 *val_pointer
= (long) get_absolute_expression ();
4732 return (*input_line_pointer
++);
4736 * demand_copy_C_string()
4738 * Like demand_copy_string, but return NULL if the string contains any '\0's.
4739 * Give a warning if that happens.
4742 demand_copy_C_string (len_pointer
)
4747 if ((s
= demand_copy_string (len_pointer
)) != 0)
4751 for (len
= *len_pointer
; len
> 0; len
--)
4758 as_bad (_("This string may not contain \'\\0\'"));
4766 * demand_copy_string()
4768 * Demand string, but return a safe (=private) copy of the string.
4769 * Return NULL if we can't read a string here.
4772 demand_copy_string (lenP
)
4775 register unsigned int c
;
4781 if (*input_line_pointer
== '\"')
4783 input_line_pointer
++; /* Skip opening quote. */
4785 while (is_a_char (c
= next_char_of_string ()))
4787 obstack_1grow (¬es
, c
);
4790 /* JF this next line is so demand_copy_C_string will return a
4791 null terminated string. */
4792 obstack_1grow (¬es
, '\0');
4793 retval
= obstack_finish (¬es
);
4797 as_warn (_("Missing string"));
4799 ignore_rest_of_line ();
4803 } /* demand_copy_string() */
4806 * is_it_end_of_statement()
4808 * In: Input_line_pointer->next character.
4810 * Do: Skip input_line_pointer over all whitespace.
4812 * Out: 1 if input_line_pointer->end-of-line.
4815 is_it_end_of_statement ()
4818 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4819 } /* is_it_end_of_statement() */
4822 equals (sym_name
, reassign
)
4826 register symbolS
*symbolP
; /* symbol we are working with */
4830 input_line_pointer
++;
4831 if (*input_line_pointer
== '=')
4832 input_line_pointer
++;
4834 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4835 input_line_pointer
++;
4838 stop
= mri_comment_field (&stopc
);
4840 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4842 /* Turn '. = mumble' into a .org mumble */
4843 register segT segment
;
4846 segment
= get_known_segmented_expression (&exp
);
4848 do_org (segment
, &exp
, 0);
4852 symbolP
= symbol_find_or_make (sym_name
);
4853 /* Permit register names to be redefined. */
4855 && S_IS_DEFINED (symbolP
)
4856 && S_GET_SEGMENT (symbolP
) != reg_section
)
4857 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
4858 pseudo_set (symbolP
);
4863 ignore_rest_of_line (); /* check garbage after the expression */
4864 mri_comment_end (stop
, stopc
);
4868 /* .include -- include a file at this point. */
4873 int arg ATTRIBUTE_UNUSED
;
4881 if (! flag_m68k_mri
)
4883 filename
= demand_copy_string (&i
);
4884 if (filename
== NULL
)
4886 /* demand_copy_string has already printed an error and
4887 called ignore_rest_of_line. */
4895 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
4896 && *input_line_pointer
!= ' '
4897 && *input_line_pointer
!= '\t')
4899 obstack_1grow (¬es
, *input_line_pointer
);
4900 ++input_line_pointer
;
4903 obstack_1grow (¬es
, '\0');
4904 filename
= obstack_finish (¬es
);
4905 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
4906 ++input_line_pointer
;
4908 demand_empty_rest_of_line ();
4909 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
4910 for (i
= 0; i
< include_dir_count
; i
++)
4912 strcpy (path
, include_dirs
[i
]);
4914 strcat (path
, filename
);
4915 if (0 != (try = fopen (path
, "r")))
4924 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
4925 register_dependency (path
);
4926 newbuf
= input_scrub_include_file (path
, input_line_pointer
);
4927 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
4931 add_include_dir (path
)
4936 if (include_dir_count
== 0)
4938 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
4939 include_dirs
[0] = "."; /* Current dir */
4940 include_dir_count
= 2;
4944 include_dir_count
++;
4945 include_dirs
= (char **) realloc (include_dirs
,
4946 include_dir_count
* sizeof (*include_dirs
));
4949 include_dirs
[include_dir_count
- 1] = path
; /* New one */
4952 if (i
> include_dir_maxlen
)
4953 include_dir_maxlen
= i
;
4954 } /* add_include_dir() */
4956 /* Output debugging information to denote the source file. */
4959 generate_file_debug ()
4961 if (debug_type
== DEBUG_STABS
)
4962 stabs_generate_asm_file ();
4965 /* Output line number debugging information for the current source line. */
4968 generate_lineno_debug ()
4970 #ifdef ECOFF_DEBUGGING
4971 /* ECOFF assemblers automatically generate debugging information.
4972 FIXME: This should probably be handled elsewhere. */
4973 if (debug_type
== DEBUG_UNSPECIFIED
)
4975 if (ECOFF_DEBUGGING
&& ecoff_no_current_file ())
4976 debug_type
= DEBUG_ECOFF
;
4978 debug_type
= DEBUG_NONE
;
4984 case DEBUG_UNSPECIFIED
:
4988 stabs_generate_asm_lineno ();
4991 ecoff_generate_asm_lineno ();
5000 /* Output debugging information to mark a function entry point or end point.
5001 END_P is zero for .func, and non-zero for .endfunc. */
5007 do_s_func (end_p
, NULL
);
5010 /* Subroutine of s_func so targets can choose a different default prefix.
5011 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5014 do_s_func (end_p
, default_prefix
)
5016 const char *default_prefix
;
5018 /* Record the current function so that we can issue an error message for
5019 misplaced .func,.endfunc, and also so that .endfunc needs no
5021 static char *current_name
;
5022 static char *current_label
;
5026 if (current_name
== NULL
)
5028 as_bad (_("missing .func"));
5029 ignore_rest_of_line ();
5033 if (debug_type
== DEBUG_STABS
)
5034 stabs_generate_asm_endfunc (current_name
, current_label
);
5036 current_name
= current_label
= NULL
;
5043 if (current_name
!= NULL
)
5045 as_bad (_(".endfunc missing for previous .func"));
5046 ignore_rest_of_line ();
5050 name
= input_line_pointer
;
5051 delim1
= get_symbol_end ();
5052 name
= xstrdup (name
);
5053 *input_line_pointer
= delim1
;
5055 if (*input_line_pointer
!= ',')
5058 asprintf (&label
, "%s%s", default_prefix
, name
);
5061 char leading_char
= 0;
5062 #ifdef BFD_ASSEMBLER
5063 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5065 /* Missing entry point, use function's name with the leading
5068 asprintf (&label
, "%c%s", leading_char
, name
);
5075 ++input_line_pointer
;
5077 label
= input_line_pointer
;
5078 delim2
= get_symbol_end ();
5079 label
= xstrdup (label
);
5080 *input_line_pointer
= delim2
;
5083 if (debug_type
== DEBUG_STABS
)
5084 stabs_generate_asm_func (name
, label
);
5086 current_name
= name
;
5087 current_label
= label
;
5090 demand_empty_rest_of_line ();
5095 int arg ATTRIBUTE_UNUSED
;
5097 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5099 ++input_line_pointer
;
5101 ++input_line_pointer
;
5106 read_print_statistics (file
)
5109 hash_print_statistics (file
, "pseudo-op table", po_hash
);