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 /* If your chars aren't 8 bits, you will change this a bit.
24 But then, GNU isn't spozed to run on your machine anyway.
25 (RMS is so shortsighted sometimes.) */
26 #define MASK_CHAR (0xFF)
28 #define MASK_CHAR ((int)(unsigned char) -1)
31 /* This is the largest known floating point format (for now). It will
32 grow when we do 4361 style flonums. */
33 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
35 /* Routines that read assembler source text to build spagetti in memory.
36 Another group of these functions is in the expr.c module. */
49 #ifndef TC_START_LABEL
50 #define TC_START_LABEL(x,y) (x==':')
53 /* Set by the object-format or the target. */
54 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
55 #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
60 else if ((SIZE) >= 4) \
62 else if ((SIZE) >= 2) \
70 /* The NOP_OPCODE is for the alignment fill value.
71 Fill it a nop instruction so that the disassembler does not choke
74 #define NOP_OPCODE 0x00
77 char *input_line_pointer
; /*->next char of source file to parse. */
79 #if BITS_PER_CHAR != 8
80 /* The following table is indexed by[(char)] and will break if
81 a char does not have exactly 256 states (hopefully 0:255!)! */
86 /* The m88k unfortunately uses @ as a label beginner. */
91 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
96 /* The Delta 68k assembler permits % inside label names. */
101 /* The PowerPC Windows NT assemblers permits ? inside label names. */
106 /* The IA-64 assembler uses # as a suffix designating a symbol. We include
107 it in the symbol and strip it out in tc_canonicalize_symbol_name. */
112 /* The a29k assembler does not permits labels to start with $. */
117 /* The Delta 68k assembler permits ~ at start of label names. */
121 /* Used by is_... macros. our ctype[]. */
124 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
125 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
126 0, 0, 0, LEX_HASH
, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
127 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
128 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
129 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
130 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
131 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
132 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
133 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
134 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
135 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
136 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
137 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
138 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
139 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
143 Out: 1 if this character ends a line. */
144 char is_end_of_line
[256] =
147 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, /* @abcdefghijklmno */
149 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* @abcdefghijklmno */
151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* _!"#$%&'()*+,-./ */
153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
158 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
161 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
163 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
164 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
165 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* */
168 #ifdef IGNORE_OPCODE_CASE
169 char original_case_string
[128];
172 /* Functions private to this file. */
174 static char *buffer
; /* 1st char of each buffer of lines is here. */
175 static char *buffer_limit
; /*->1 + last char in buffer. */
177 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
178 in the tc-<CPU>.h file. See the "Porting GAS" section of the
180 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
182 static char *old_buffer
; /* JF a hack. */
183 static char *old_input
;
184 static char *old_limit
;
186 /* Variables for handling include file directory table. */
188 /* Table of pointers to directories to search for .include's. */
191 /* How many are in the table. */
192 int include_dir_count
;
194 /* Length of longest in table. */
195 int include_dir_maxlen
= 1;
197 #ifndef WORKING_DOT_WORD
198 struct broken_word
*broken_words
;
199 int new_broken_words
;
202 /* The current offset into the absolute section. We don't try to
203 build frags in the absolute section, since no data can be stored
204 there. We just keep track of the current offset. */
205 addressT abs_section_offset
;
207 /* If this line had an MRI style label, it is stored in this variable.
208 This is used by some of the MRI pseudo-ops. */
211 /* This global variable is used to support MRI common sections. We
212 translate such sections into a common symbol. This variable is
213 non-NULL when we are in an MRI common section. */
214 symbolS
*mri_common_symbol
;
216 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
217 need to align to an even byte boundary unless the next pseudo-op is
218 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
220 static int mri_pending_align
;
224 /* This variable is set to be non-zero if the next string we see might
225 be the name of the source file in DWARF debugging information. See
226 the comment in emit_expr for the format we look for. */
227 static int dwarf_file_string
;
231 static void cons_worker
PARAMS ((int, int));
232 static int scrub_from_string
PARAMS ((char *, int));
233 static void do_align
PARAMS ((int, char *, int, int));
234 static void s_align
PARAMS ((int, int));
235 static void s_lcomm_internal
PARAMS ((int, int));
236 static int hex_float
PARAMS ((int, char *));
237 static inline int sizeof_sleb128
PARAMS ((offsetT
));
238 static inline int sizeof_uleb128
PARAMS ((valueT
));
239 static inline int output_sleb128
PARAMS ((char *, offsetT
));
240 static inline int output_uleb128
PARAMS ((char *, valueT
));
241 static inline int output_big_sleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
242 static inline int output_big_uleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
243 static int output_big_leb128
PARAMS ((char *, LITTLENUM_TYPE
*, int, int));
244 static void do_org
PARAMS ((segT
, expressionS
*, int));
245 char *demand_copy_string
PARAMS ((int *lenP
));
246 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
247 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
248 static void pobegin
PARAMS ((void));
249 static int get_line_sb
PARAMS ((sb
*));
250 static void generate_file_debug
PARAMS ((void));
258 obj_read_begin_hook ();
260 /* Something close -- but not too close -- to a multiple of 1024.
261 The debugging malloc I'm using has 24 bytes of overhead. */
262 obstack_begin (¬es
, chunksize
);
263 obstack_begin (&cond_obstack
, chunksize
);
265 /* Use machine dependent syntax. */
266 for (p
= line_separator_chars
; *p
; p
++)
267 is_end_of_line
[(unsigned char) *p
] = 1;
268 /* Use more. FIXME-SOMEDAY. */
274 /* Set up pseudo-op tables. */
276 static struct hash_control
*po_hash
;
278 static const pseudo_typeS potable
[] =
280 {"abort", s_abort
, 0},
281 {"align", s_align_ptwo
, 0},
282 {"ascii", stringer
, 0},
283 {"asciz", stringer
, 1},
284 {"balign", s_align_bytes
, 0},
285 {"balignw", s_align_bytes
, -2},
286 {"balignl", s_align_bytes
, -4},
290 {"common", s_mri_common
, 0},
291 {"common.s", s_mri_common
, 1},
295 {"dc.d", float_cons
, 'd'},
297 {"dc.s", float_cons
, 'f'},
299 {"dc.x", float_cons
, 'x'},
301 {"dcb.b", s_space
, 1},
302 {"dcb.d", s_float_space
, 'd'},
303 {"dcb.l", s_space
, 4},
304 {"dcb.s", s_float_space
, 'f'},
305 {"dcb.w", s_space
, 2},
306 {"dcb.x", s_float_space
, 'x'},
308 {"ds.b", s_space
, 1},
309 {"ds.d", s_space
, 8},
310 {"ds.l", s_space
, 4},
311 {"ds.p", s_space
, 12},
312 {"ds.s", s_space
, 4},
313 {"ds.w", s_space
, 2},
314 {"ds.x", s_space
, 12},
315 {"debug", s_ignore
, 0},
320 {"double", float_cons
, 'd'},
322 {"eject", listing_eject
, 0}, /* Formfeed listing. */
324 {"elsec", s_else
, 0},
325 {"elseif", s_elseif
, (int) O_ne
},
327 {"endc", s_endif
, 0},
328 {"endfunc", s_func
, 1},
329 {"endif", s_endif
, 0},
334 {"exitm", s_mexit
, 0},
336 {"extern", s_ignore
, 0}, /* We treat all undef as ext. */
337 {"appfile", s_app_file
, 1},
338 {"appline", s_app_line
, 0},
340 {"file", s_app_file
, 0},
342 {"float", float_cons
, 'f'},
343 {"format", s_ignore
, 0},
345 {"global", s_globl
, 0},
346 {"globl", s_globl
, 0},
348 {"if", s_if
, (int) O_ne
},
350 {"ifdef", s_ifdef
, 0},
351 {"ifeq", s_if
, (int) O_eq
},
352 {"ifeqs", s_ifeqs
, 0},
353 {"ifge", s_if
, (int) O_ge
},
354 {"ifgt", s_if
, (int) O_gt
},
355 {"ifle", s_if
, (int) O_le
},
356 {"iflt", s_if
, (int) O_lt
},
358 {"ifndef", s_ifdef
, 1},
359 {"ifne", s_if
, (int) O_ne
},
360 {"ifnes", s_ifeqs
, 1},
361 {"ifnotdef", s_ifdef
, 1},
362 {"include", s_include
, 0},
368 {"lcomm", s_lcomm
, 0},
369 {"lflags", listing_flags
, 0}, /* Listing flags. */
370 {"linkonce", s_linkonce
, 0},
371 {"list", listing_list
, 1}, /* Turn listing on. */
372 {"llen", listing_psize
, 1},
375 {"macro", s_macro
, 0},
376 {"mexit", s_mexit
, 0},
378 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
379 {"name", s_ignore
, 0},
380 {"noformat", s_ignore
, 0},
381 {"nolist", listing_list
, 0}, /* Turn listing off. */
382 {"nopage", listing_nopage
, 0},
384 {"offset", s_struct
, 0},
386 {"p2align", s_align_ptwo
, 0},
387 {"p2alignw", s_align_ptwo
, -2},
388 {"p2alignl", s_align_ptwo
, -4},
389 {"page", listing_eject
, 0},
390 {"plen", listing_psize
, 0},
391 {"print", s_print
, 0},
392 {"psize", listing_psize
, 0}, /* Set paper size. */
393 {"purgem", s_purgem
, 0},
398 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
403 {"single", float_cons
, 'f'},
405 {"space", s_space
, 0},
406 {"skip", s_space
, 0},
407 {"sleb128", s_leb128
, 1},
408 {"spc", s_ignore
, 0},
409 {"stabd", s_stab
, 'd'},
410 {"stabn", s_stab
, 'n'},
411 {"stabs", s_stab
, 's'},
412 {"string", stringer
, 1},
413 {"struct", s_struct
, 0},
417 /* This is for gcc to use. It's only just been added (2/94), so gcc
418 won't be able to use it for a while -- probably a year or more.
419 But once this has been released, check with gcc maintainers
420 before deleting it or even changing the spelling. */
421 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
422 /* If we're folding case -- done for some targets, not necessarily
423 all -- the above string in an input file will be converted to
424 this one. Match it either way... */
425 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
427 {"title", listing_title
, 0}, /* Listing title. */
428 {"ttl", listing_title
, 0},
430 {"uleb128", s_leb128
, 0},
434 {"xdef", s_globl
, 0},
435 {"xref", s_ignore
, 0},
436 {"xstabs", s_xstab
, 's'},
438 {"zero", s_space
, 0},
439 {NULL
, NULL
, 0} /* End sentinel. */
442 static int pop_override_ok
= 0;
443 static const char *pop_table_name
;
447 const pseudo_typeS
*table
;
450 const pseudo_typeS
*pop
;
451 for (pop
= table
; pop
->poc_name
; pop
++)
453 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
454 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
455 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
460 #ifndef md_pop_insert
461 #define md_pop_insert() pop_insert(md_pseudo_table)
464 #ifndef obj_pop_insert
465 #define obj_pop_insert() pop_insert(obj_pseudo_table)
471 po_hash
= hash_new ();
473 /* Do the target-specific pseudo ops. */
474 pop_table_name
= "md";
477 /* Now object specific. Skip any that were in the target table. */
478 pop_table_name
= "obj";
482 /* Now portable ones. Skip any that we've seen already. */
483 pop_table_name
= "standard";
484 pop_insert (potable
);
487 #define HANDLE_CONDITIONAL_ASSEMBLY() \
488 if (ignore_input ()) \
490 while (!is_end_of_line[(unsigned char) *input_line_pointer++]) \
491 if (input_line_pointer == buffer_limit) \
496 /* This function is used when scrubbing the characters between #APP
499 static char *scrub_string
;
500 static char *scrub_string_end
;
503 scrub_from_string (buf
, buflen
)
509 copy
= scrub_string_end
- scrub_string
;
512 memcpy (buf
, scrub_string
, copy
);
513 scrub_string
+= copy
;
517 /* We read the file, putting things into a web that represents what we
518 have been reading. */
520 read_a_source_file (name
)
524 register char *s
; /* String of symbol, '\0' appended. */
532 buffer
= input_scrub_new_file (name
);
535 listing_newline (NULL
);
536 register_dependency (name
);
538 /* Generate debugging information before we've read anything in to denote
539 this file as the "main" source file and not a subordinate one
540 (e.g. N_SO vs N_SOL in stabs). */
541 generate_file_debug ();
543 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
544 { /* We have another line to parse. */
545 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
546 contin
: /* JF this goto is my fault I admit it.
547 Someone brave please re-write the whole
548 input section here? Pleeze??? */
549 while (input_line_pointer
< buffer_limit
)
551 /* We have more of this buffer to parse. */
553 /* We now have input_line_pointer->1st char of next line.
554 If input_line_pointer [-1] == '\n' then we just
555 scanned another line: so bump line counters. */
556 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
558 #ifdef md_start_line_hook
559 md_start_line_hook ();
561 if (input_line_pointer
[-1] == '\n')
562 bump_line_counters ();
566 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
568 /* Text at the start of a line must be a label, we
569 run down and stick a colon in. */
570 if (is_name_beginner (*input_line_pointer
))
572 char *line_start
= input_line_pointer
;
577 HANDLE_CONDITIONAL_ASSEMBLY ();
579 c
= get_symbol_end ();
581 /* In MRI mode, the EQU and MACRO pseudoops must
582 be handled specially. */
586 char *rest
= input_line_pointer
+ 1;
590 if (*rest
== ' ' || *rest
== '\t')
592 if ((strncasecmp (rest
, "EQU", 3) == 0
593 || strncasecmp (rest
, "SET", 3) == 0)
594 && (rest
[3] == ' ' || rest
[3] == '\t'))
596 input_line_pointer
= rest
+ 3;
598 strncasecmp (rest
, "SET", 3) == 0);
601 if (strncasecmp (rest
, "MACRO", 5) == 0
604 || is_end_of_line
[(unsigned char) rest
[5]]))
608 /* In MRI mode, we need to handle the MACRO
609 pseudo-op specially: we don't want to put the
610 symbol in the symbol table. */
612 #ifdef TC_START_LABEL_WITHOUT_COLON
613 && TC_START_LABEL_WITHOUT_COLON(c
,
617 line_label
= colon (line_start
);
619 line_label
= symbol_create (line_start
,
624 *input_line_pointer
= c
;
626 input_line_pointer
++;
631 /* We are at the begining of a line, or similar place.
632 We expect a well-formed assembler statement.
633 A "symbol-name:" is a statement.
635 Depending on what compiler is used, the order of these tests
636 may vary to catch most common case 1st.
637 Each test is independent of all other tests at the (top) level.
638 PLEASE make a compiler that doesn't use this assembler.
639 It is crufty to waste a compiler's time encoding things for this
640 assembler, which then wastes more time decoding it.
641 (And communicating via (linear) files is silly!
642 If you must pass stuff, please pass a tree!) */
643 if ((c
= *input_line_pointer
++) == '\t'
647 c
= *input_line_pointer
++;
649 know (c
!= ' '); /* No further leading whitespace. */
652 /* If listing is on, and we are expanding a macro, then give
653 the listing code the contents of the expanded line. */
656 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
661 /* Find the end of the current expanded macro line. */
662 for (s
= input_line_pointer
- 1; *s
; ++s
)
663 if (is_end_of_line
[(unsigned char) *s
])
666 /* Copy it for safe keeping. Also give an indication of
667 how much macro nesting is involved at this point. */
668 len
= s
- (input_line_pointer
-1);
669 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
670 memset (copy
, '>', macro_nest
);
671 copy
[macro_nest
] = ' ';
672 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
- 1, len
);
673 copy
[macro_nest
+ 1 + len
] = '\0';
675 /* Install the line with the listing facility. */
676 listing_newline (copy
);
679 listing_newline (NULL
);
682 /* C is the 1st significant character.
683 Input_line_pointer points after that character. */
684 if (is_name_beginner (c
))
686 /* Want user-defined label or pseudo/opcode. */
687 HANDLE_CONDITIONAL_ASSEMBLY ();
689 s
= --input_line_pointer
;
690 c
= get_symbol_end (); /* name's delimiter. */
692 /* C is character after symbol.
693 That character's place in the input line is now '\0'.
694 S points to the beginning of the symbol.
695 [In case of pseudo-op, s->'.'.]
696 Input_line_pointer->'\0' where c was. */
697 if (TC_START_LABEL (c
, input_line_pointer
))
701 char *rest
= input_line_pointer
+ 1;
703 /* In MRI mode, \tsym: set 0 is permitted. */
707 if (*rest
== ' ' || *rest
== '\t')
710 if ((strncasecmp (rest
, "EQU", 3) == 0
711 || strncasecmp (rest
, "SET", 3) == 0)
712 && (rest
[3] == ' ' || rest
[3] == '\t'))
714 input_line_pointer
= rest
+ 3;
720 line_label
= colon (s
); /* User-defined label. */
721 /* Put ':' back for error messages' sake. */
722 *input_line_pointer
++ = ':';
723 /* Input_line_pointer->after ':'. */
727 || ((c
== ' ' || c
== '\t')
728 && input_line_pointer
[1] == '='
729 #ifdef TC_EQUAL_IN_INSN
730 && !TC_EQUAL_IN_INSN (c
, input_line_pointer
)
735 demand_empty_rest_of_line ();
739 /* Expect pseudo-op or machine instruction. */
742 #ifdef IGNORE_OPCODE_CASE
746 strncpy (original_case_string
, s2
, sizeof (original_case_string
));
747 original_case_string
[sizeof (original_case_string
) - 1] = 0;
751 if (isupper ((unsigned char) *s2
))
757 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
759 /* The MRI assembler and the m88k use pseudo-ops
761 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
762 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
767 || (!flag_m68k_mri
&& *s
== '.'))
771 WARNING: c has next char, which may be end-of-line.
772 We lookup the pseudo-op table with s+1 because we
773 already know that the pseudo-op begins with a '.'. */
776 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
778 /* In MRI mode, we may need to insert an
779 automatic alignment directive. What a hack
781 if (mri_pending_align
783 || !((pop
->poc_handler
== cons
784 && pop
->poc_val
== 1)
785 || (pop
->poc_handler
== s_space
786 && pop
->poc_val
== 1)
787 #ifdef tc_conditional_pseudoop
788 || tc_conditional_pseudoop (pop
)
790 || pop
->poc_handler
== s_if
791 || pop
->poc_handler
== s_ifdef
792 || pop
->poc_handler
== s_ifc
793 || pop
->poc_handler
== s_ifeqs
794 || pop
->poc_handler
== s_else
795 || pop
->poc_handler
== s_endif
796 || pop
->poc_handler
== s_globl
797 || pop
->poc_handler
== s_ignore
)))
799 do_align (1, (char *) NULL
, 0, 0);
800 mri_pending_align
= 0;
802 if (line_label
!= NULL
)
804 symbol_set_frag (line_label
, frag_now
);
805 S_SET_VALUE (line_label
, frag_now_fix ());
809 /* Print the error msg now, while we still can. */
812 as_bad (_("Unknown pseudo-op: `%s'"), s
);
813 *input_line_pointer
= c
;
818 /* Put it back for error messages etc. */
819 *input_line_pointer
= c
;
820 /* The following skip of whitespace is compulsory.
821 A well shaped space is sometimes all that separates
822 keyword from operands. */
823 if (c
== ' ' || c
== '\t')
824 input_line_pointer
++;
826 /* Input_line is restored.
827 Input_line_pointer->1st non-blank char
828 after pseudo-operation. */
829 (*pop
->poc_handler
) (pop
->poc_val
);
831 /* If that was .end, just get out now. */
832 if (pop
->poc_handler
== s_end
)
838 #ifdef QUOTES_IN_INSN
842 /* WARNING: c has char, which may be end-of-line. */
843 /* Also: input_line_pointer->`\0` where c was. */
844 *input_line_pointer
= c
;
845 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
847 #ifdef TC_EOL_IN_INSN
848 || TC_EOL_IN_INSN (input_line_pointer
)
852 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
854 #ifdef QUOTES_IN_INSN
857 else if (*input_line_pointer
== '"')
859 else if (*input_line_pointer
== '\\')
862 input_line_pointer
++;
865 c
= *input_line_pointer
;
866 *input_line_pointer
= '\0';
868 generate_lineno_debug ();
876 if (check_macro (s
, &out
, '\0', &err
, ¯o
))
880 *input_line_pointer
++ = c
;
881 input_scrub_include_sb (&out
,
882 input_line_pointer
, 1);
885 input_scrub_next_buffer (&input_line_pointer
);
887 md_macro_info (macro
);
893 if (mri_pending_align
)
895 do_align (1, (char *) NULL
, 0, 0);
896 mri_pending_align
= 0;
897 if (line_label
!= NULL
)
899 symbol_set_frag (line_label
, frag_now
);
900 S_SET_VALUE (line_label
, frag_now_fix ());
904 md_assemble (s
); /* Assemble 1 instruction. */
906 *input_line_pointer
++ = c
;
908 /* We resume loop AFTER the end-of-line from
915 /* Empty statement? */
916 if (is_end_of_line
[(unsigned char) c
])
919 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
920 && isdigit ((unsigned char) c
))
922 /* local label ("4:") */
923 char *backup
= input_line_pointer
;
925 HANDLE_CONDITIONAL_ASSEMBLY ();
929 /* Read the whole number. */
930 while (isdigit ((unsigned char) *input_line_pointer
))
932 temp
= (temp
* 10) + *input_line_pointer
- '0';
933 ++input_line_pointer
;
936 if (LOCAL_LABELS_DOLLAR
937 && *input_line_pointer
== '$'
938 && *(input_line_pointer
+ 1) == ':')
940 input_line_pointer
+= 2;
942 if (dollar_label_defined (temp
))
944 as_fatal (_("label \"%d$\" redefined"), temp
);
947 define_dollar_label (temp
);
948 colon (dollar_label_name (temp
, 0));
953 && *input_line_pointer
++ == ':')
955 fb_label_instance_inc (temp
);
956 colon (fb_label_name (temp
, 0));
960 input_line_pointer
= backup
;
961 } /* local label ("4:") */
963 if (c
&& strchr (line_comment_chars
, c
))
964 { /* Its a comment. Better say APP or NO_APP. */
968 unsigned int new_length
;
971 bump_line_counters ();
972 s
= input_line_pointer
;
973 if (strncmp (s
, "APP\n", 4))
974 continue; /* We ignore it */
977 ends
= strstr (s
, "#NO_APP\n");
981 unsigned int tmp_len
;
984 /* The end of the #APP wasn't in this buffer. We
985 keep reading in buffers until we find the #NO_APP
986 that goes with this #APP There is one. The specs
988 tmp_len
= buffer_limit
- s
;
989 tmp_buf
= xmalloc (tmp_len
+ 1);
990 memcpy (tmp_buf
, s
, tmp_len
);
993 new_tmp
= input_scrub_next_buffer (&buffer
);
997 buffer_limit
= new_tmp
;
998 input_line_pointer
= buffer
;
999 ends
= strstr (buffer
, "#NO_APP\n");
1001 num
= ends
- buffer
;
1003 num
= buffer_limit
- buffer
;
1005 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
1006 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
1011 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1019 input_line_pointer
= ends
+ 8;
1023 scrub_string_end
= ends
;
1025 new_length
= ends
- s
;
1026 new_buf
= (char *) xmalloc (new_length
);
1033 space
= (new_buf
+ new_length
) - new_tmp
;
1034 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1042 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1043 new_tmp
= new_buf
+ new_length
;
1049 old_buffer
= buffer
;
1050 old_input
= input_line_pointer
;
1051 old_limit
= buffer_limit
;
1053 input_line_pointer
= new_buf
;
1054 buffer_limit
= new_tmp
;
1059 HANDLE_CONDITIONAL_ASSEMBLY ();
1061 #ifdef tc_unrecognized_line
1062 if (tc_unrecognized_line (c
))
1065 /* as_warn (_("Junk character %d."),c); Now done by ignore_rest. */
1066 input_line_pointer
--; /* Report unknown char as ignored. */
1067 ignore_rest_of_line ();
1070 #ifdef md_after_pass_hook
1071 md_after_pass_hook ();
1077 bump_line_counters ();
1080 buffer
= old_buffer
;
1081 input_line_pointer
= old_input
;
1082 buffer_limit
= old_limit
;
1094 /* Close the input file. */
1095 input_scrub_close ();
1096 #ifdef WARN_COMMENTS
1098 if (warn_comment
&& found_comment
)
1099 as_warn_where (found_comment_file
, found_comment
,
1100 "first comment found here");
1105 /* For most MRI pseudo-ops, the line actually ends at the first
1106 nonquoted space. This function looks for that point, stuffs a null
1107 in, and sets *STOPCP to the character that used to be there, and
1108 returns the location.
1110 Until I hear otherwise, I am going to assume that this is only true
1111 for the m68k MRI assembler. */
1114 mri_comment_field (stopcp
)
1121 know (flag_m68k_mri
);
1123 for (s
= input_line_pointer
;
1124 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1132 for (s
= input_line_pointer
;
1133 !is_end_of_line
[(unsigned char) *s
];
1143 /* Skip to the end of an MRI comment field. */
1146 mri_comment_end (stop
, stopc
)
1152 input_line_pointer
= stop
;
1154 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1155 ++input_line_pointer
;
1160 int ignore ATTRIBUTE_UNUSED
;
1162 as_fatal (_(".abort detected. Abandoning ship."));
1165 /* Guts of .align directive. N is the power of two to which to align.
1166 FILL may be NULL, or it may point to the bytes of the fill pattern.
1167 LEN is the length of whatever FILL points to, if anything. MAX is
1168 the maximum number of characters to skip when doing the alignment,
1169 or 0 if there is no maximum. */
1172 do_align (n
, fill
, len
, max
)
1181 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1186 if (subseg_text_p (now_seg
))
1187 default_fill
= NOP_OPCODE
;
1190 fill
= &default_fill
;
1194 /* Only make a frag if we HAVE to... */
1195 if (n
!= 0 && !need_pass_2
)
1198 frag_align (n
, *fill
, max
);
1200 frag_align_pattern (n
, fill
, len
, max
);
1204 just_record_alignment
:
1207 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1210 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1211 (in bytes). A negative ARG is the negative of the length of the
1212 fill pattern. BYTES_P is non-zero if the alignment value should be
1213 interpreted as the byte boundary, rather than the power of 2. */
1216 s_align (arg
, bytes_p
)
1220 register unsigned int align
;
1228 stop
= mri_comment_field (&stopc
);
1230 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1235 align
= arg
; /* Default value from pseudo-op table. */
1239 align
= get_absolute_expression ();
1245 /* Convert to a power of 2. */
1250 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1253 as_bad (_("Alignment not a power of 2"));
1262 as_bad (_("Alignment too large: %u assumed"), align
);
1265 if (*input_line_pointer
!= ',')
1272 ++input_line_pointer
;
1273 if (*input_line_pointer
== ',')
1277 fill
= get_absolute_expression ();
1282 if (*input_line_pointer
!= ',')
1286 ++input_line_pointer
;
1287 max
= get_absolute_expression ();
1294 as_warn (_("expected fill pattern missing"));
1295 do_align (align
, (char *) NULL
, 0, max
);
1310 do_align (align
, &fill_char
, fill_len
, max
);
1316 if ((size_t) fill_len
> sizeof ab
)
1318 md_number_to_chars (ab
, fill
, fill_len
);
1319 do_align (align
, ab
, fill_len
, max
);
1323 demand_empty_rest_of_line ();
1326 mri_comment_end (stop
, stopc
);
1329 /* Handle the .align pseudo-op on machines where ".align 4" means
1330 align to a 4 byte boundary. */
1339 /* Handle the .align pseudo-op on machines where ".align 4" means align
1340 to a 2**4 boundary. */
1351 int ignore ATTRIBUTE_UNUSED
;
1353 register char *name
;
1357 register symbolS
*symbolP
;
1362 stop
= mri_comment_field (&stopc
);
1364 name
= input_line_pointer
;
1365 c
= get_symbol_end ();
1366 /* Just after name is now '\0'. */
1367 p
= input_line_pointer
;
1371 if (*input_line_pointer
!= ',')
1373 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1374 ignore_rest_of_line ();
1376 mri_comment_end (stop
, stopc
);
1380 input_line_pointer
++; /* skip ',' */
1382 if ((temp
= get_absolute_expression ()) < 0)
1384 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
1385 ignore_rest_of_line ();
1387 mri_comment_end (stop
, stopc
);
1392 symbolP
= symbol_find_or_make (name
);
1395 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1397 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1398 S_GET_NAME (symbolP
));
1399 ignore_rest_of_line ();
1401 mri_comment_end (stop
, stopc
);
1405 if (S_GET_VALUE (symbolP
))
1407 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1408 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
1409 S_GET_NAME (symbolP
),
1410 (long) S_GET_VALUE (symbolP
),
1415 S_SET_VALUE (symbolP
, (valueT
) temp
);
1416 S_SET_EXTERNAL (symbolP
);
1420 extern int flag_one
;
1421 if (!temp
|| !flag_one
)
1422 S_GET_OTHER(symbolP
) = const_flag
;
1424 #endif /* not OBJ_VMS */
1425 know (symbolP
->sy_frag
== &zero_address_frag
);
1427 demand_empty_rest_of_line ();
1430 mri_comment_end (stop
, stopc
);
1433 /* The MRI COMMON pseudo-op. We handle this by creating a common
1434 symbol with the appropriate name. We make s_space do the right
1435 thing by increasing the size. */
1438 s_mri_common (small
)
1439 int small ATTRIBUTE_UNUSED
;
1455 stop
= mri_comment_field (&stopc
);
1459 name
= input_line_pointer
;
1460 if (!isdigit ((unsigned char) *name
))
1461 c
= get_symbol_end ();
1466 ++input_line_pointer
;
1468 while (isdigit ((unsigned char) *input_line_pointer
));
1470 c
= *input_line_pointer
;
1471 *input_line_pointer
= '\0';
1473 if (line_label
!= NULL
)
1475 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1476 + (input_line_pointer
- name
)
1478 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1483 sym
= symbol_find_or_make (name
);
1484 *input_line_pointer
= c
;
1488 if (*input_line_pointer
!= ',')
1492 ++input_line_pointer
;
1493 align
= get_absolute_expression ();
1496 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1498 as_bad (_("attempt to re-define symbol `%s'"), S_GET_NAME (sym
));
1499 ignore_rest_of_line ();
1500 mri_comment_end (stop
, stopc
);
1504 S_SET_EXTERNAL (sym
);
1505 mri_common_symbol
= sym
;
1509 S_SET_ALIGN (sym
, align
);
1512 if (line_label
!= NULL
)
1515 exp
.X_op
= O_symbol
;
1516 exp
.X_add_symbol
= sym
;
1517 exp
.X_add_number
= 0;
1518 symbol_set_value_expression (line_label
, &exp
);
1519 symbol_set_frag (line_label
, &zero_address_frag
);
1520 S_SET_SEGMENT (line_label
, expr_section
);
1523 /* FIXME: We just ignore the small argument, which distinguishes
1524 COMMON and COMMON.S. I don't know what we can do about it. */
1526 /* Ignore the type and hptype. */
1527 if (*input_line_pointer
== ',')
1528 input_line_pointer
+= 2;
1529 if (*input_line_pointer
== ',')
1530 input_line_pointer
+= 2;
1532 demand_empty_rest_of_line ();
1534 mri_comment_end (stop
, stopc
);
1539 int ignore ATTRIBUTE_UNUSED
;
1544 temp
= get_absolute_expression ();
1545 if (flag_readonly_data_in_text
)
1547 section
= text_section
;
1551 section
= data_section
;
1553 subseg_set (section
, (subsegT
) temp
);
1558 demand_empty_rest_of_line ();
1561 /* Handle the .appfile pseudo-op. This is automatically generated by
1562 do_scrub_chars when a preprocessor # line comment is seen with a
1563 file name. This default definition may be overridden by the object
1564 or CPU specific pseudo-ops. This function is also the default
1565 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1569 s_app_file (appfile
)
1575 /* Some assemblers tolerate immediately following '"'. */
1576 if ((s
= demand_copy_string (&length
)) != 0)
1578 /* If this is a fake .appfile, a fake newline was inserted into
1579 the buffer. Passing -2 to new_logical_line tells it to
1582 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1584 /* In MRI mode, the preprocessor may have inserted an extraneous
1587 && *input_line_pointer
== '\''
1588 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1589 ++input_line_pointer
;
1591 demand_empty_rest_of_line ();
1596 listing_source_file (s
);
1598 register_dependency (s
);
1606 /* Handle the .appline pseudo-op. This is automatically generated by
1607 do_scrub_chars when a preprocessor # line comment is seen. This
1608 default definition may be overridden by the object or CPU specific
1613 int ignore ATTRIBUTE_UNUSED
;
1617 /* The given number is that of the next line. */
1618 l
= get_absolute_expression () - 1;
1620 /* Some of the back ends can't deal with non-positive line numbers.
1621 Besides, it's silly. */
1622 as_warn (_("Line numbers must be positive; line number %d rejected."),
1626 new_logical_line ((char *) NULL
, l
);
1629 listing_source_line (l
);
1632 demand_empty_rest_of_line ();
1635 /* Handle the .end pseudo-op. Actually, the real work is done in
1636 read_a_source_file. */
1640 int ignore ATTRIBUTE_UNUSED
;
1644 /* The MRI assembler permits the start symbol to follow .end,
1645 but we don't support that. */
1647 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1648 && *input_line_pointer
!= '*'
1649 && *input_line_pointer
!= '!')
1650 as_warn (_("start address not supported"));
1654 /* Handle the .err pseudo-op. */
1658 int ignore ATTRIBUTE_UNUSED
;
1660 as_bad (_(".err encountered"));
1661 demand_empty_rest_of_line ();
1664 /* Handle the MRI fail pseudo-op. */
1668 int ignore ATTRIBUTE_UNUSED
;
1675 stop
= mri_comment_field (&stopc
);
1677 temp
= get_absolute_expression ();
1679 as_warn (_(".fail %ld encountered"), (long) temp
);
1681 as_bad (_(".fail %ld encountered"), (long) temp
);
1683 demand_empty_rest_of_line ();
1686 mri_comment_end (stop
, stopc
);
1691 int ignore ATTRIBUTE_UNUSED
;
1693 expressionS rep_exp
;
1695 register long fill
= 0;
1698 #ifdef md_flush_pending_output
1699 md_flush_pending_output ();
1702 get_known_segmented_expression (&rep_exp
);
1703 if (*input_line_pointer
== ',')
1705 input_line_pointer
++;
1706 size
= get_absolute_expression ();
1707 if (*input_line_pointer
== ',')
1709 input_line_pointer
++;
1710 fill
= get_absolute_expression ();
1714 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1715 #define BSD_FILL_SIZE_CROCK_8 (8)
1716 if (size
> BSD_FILL_SIZE_CROCK_8
)
1718 as_warn (_(".fill size clamped to %d."), BSD_FILL_SIZE_CROCK_8
);
1719 size
= BSD_FILL_SIZE_CROCK_8
;
1723 as_warn (_("Size negative: .fill ignored."));
1726 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1728 if (rep_exp
.X_add_number
< 0)
1729 as_warn (_("Repeat < 0, .fill ignored"));
1733 if (size
&& !need_pass_2
)
1735 if (rep_exp
.X_op
== O_constant
)
1737 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1738 (relax_substateT
) 0, (symbolS
*) 0,
1739 (offsetT
) rep_exp
.X_add_number
,
1744 /* We don't have a constant repeat count, so we can't use
1745 rs_fill. We can get the same results out of rs_space,
1746 but its argument is in bytes, so we must multiply the
1747 repeat count by size. */
1750 rep_sym
= make_expr_symbol (&rep_exp
);
1753 expressionS size_exp
;
1754 size_exp
.X_op
= O_constant
;
1755 size_exp
.X_add_number
= size
;
1757 rep_exp
.X_op
= O_multiply
;
1758 rep_exp
.X_add_symbol
= rep_sym
;
1759 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1760 rep_exp
.X_add_number
= 0;
1761 rep_sym
= make_expr_symbol (&rep_exp
);
1764 p
= frag_var (rs_space
, (int) size
, (int) size
,
1765 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1768 memset (p
, 0, (unsigned int) size
);
1770 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1771 flavoured AS. The following bizzare behaviour is to be
1772 compatible with above. I guess they tried to take up to 8
1773 bytes from a 4-byte expression and they forgot to sign
1774 extend. Un*x Sux. */
1775 #define BSD_FILL_SIZE_CROCK_4 (4)
1776 md_number_to_chars (p
, (valueT
) fill
,
1777 (size
> BSD_FILL_SIZE_CROCK_4
1778 ? BSD_FILL_SIZE_CROCK_4
1780 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1781 but emits no error message because it seems a legal thing to do.
1782 It is a degenerate case of .fill but could be emitted by a
1785 demand_empty_rest_of_line ();
1790 int ignore ATTRIBUTE_UNUSED
;
1799 stop
= mri_comment_field (&stopc
);
1803 name
= input_line_pointer
;
1804 c
= get_symbol_end ();
1805 symbolP
= symbol_find_or_make (name
);
1806 S_SET_EXTERNAL (symbolP
);
1808 *input_line_pointer
= c
;
1810 c
= *input_line_pointer
;
1813 input_line_pointer
++;
1815 if (*input_line_pointer
== '\n')
1821 demand_empty_rest_of_line ();
1824 mri_comment_end (stop
, stopc
);
1827 /* Handle the MRI IRP and IRPC pseudo-ops. */
1839 as_where (&file
, &line
);
1842 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1843 sb_add_char (&s
, *input_line_pointer
++);
1847 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1849 as_bad_where (file
, line
, "%s", err
);
1853 input_scrub_include_sb (&out
, input_line_pointer
, 1);
1855 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1858 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1859 the section to only be linked once. However, this is not supported
1860 by most object file formats. This takes an optional argument,
1861 which is what to do about duplicates. */
1865 int ignore ATTRIBUTE_UNUSED
;
1867 enum linkonce_type type
;
1871 type
= LINKONCE_DISCARD
;
1873 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1878 s
= input_line_pointer
;
1879 c
= get_symbol_end ();
1880 if (strcasecmp (s
, "discard") == 0)
1881 type
= LINKONCE_DISCARD
;
1882 else if (strcasecmp (s
, "one_only") == 0)
1883 type
= LINKONCE_ONE_ONLY
;
1884 else if (strcasecmp (s
, "same_size") == 0)
1885 type
= LINKONCE_SAME_SIZE
;
1886 else if (strcasecmp (s
, "same_contents") == 0)
1887 type
= LINKONCE_SAME_CONTENTS
;
1889 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1891 *input_line_pointer
= c
;
1894 #ifdef obj_handle_link_once
1895 obj_handle_link_once (type
);
1896 #else /* ! defined (obj_handle_link_once) */
1897 #ifdef BFD_ASSEMBLER
1901 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1902 as_warn (_(".linkonce is not supported for this object file format"));
1904 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1905 flags
|= SEC_LINK_ONCE
;
1910 case LINKONCE_DISCARD
:
1911 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1913 case LINKONCE_ONE_ONLY
:
1914 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1916 case LINKONCE_SAME_SIZE
:
1917 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1919 case LINKONCE_SAME_CONTENTS
:
1920 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1923 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1924 as_bad (_("bfd_set_section_flags: %s"),
1925 bfd_errmsg (bfd_get_error ()));
1927 #else /* ! defined (BFD_ASSEMBLER) */
1928 as_warn (_(".linkonce is not supported for this object file format"));
1929 #endif /* ! defined (BFD_ASSEMBLER) */
1930 #endif /* ! defined (obj_handle_link_once) */
1932 demand_empty_rest_of_line ();
1936 s_lcomm_internal (needs_align
, bytes_p
)
1937 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1938 (alignment); 0 if it was an ".lcomm" (2 args only). */
1940 /* 1 if the alignment value should be interpreted as the byte boundary,
1941 rather than the power of 2. */
1944 register char *name
;
1948 register symbolS
*symbolP
;
1949 segT current_seg
= now_seg
;
1950 subsegT current_subseg
= now_subseg
;
1951 const int max_alignment
= 15;
1953 segT bss_seg
= bss_section
;
1955 name
= input_line_pointer
;
1956 c
= get_symbol_end ();
1957 p
= input_line_pointer
;
1961 /* Accept an optional comma after the name. The comma used to be
1962 required, but Irix 5 cc does not generate it. */
1963 if (*input_line_pointer
== ',')
1965 ++input_line_pointer
;
1969 if (*input_line_pointer
== '\n')
1971 as_bad (_("Missing size expression"));
1975 if ((temp
= get_absolute_expression ()) < 0)
1977 as_warn (_("BSS length (%d.) <0! Ignored."), temp
);
1978 ignore_rest_of_line ();
1982 #if defined (TC_MIPS) || defined (TC_ALPHA)
1983 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1984 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1986 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1987 if (temp
<= bfd_get_gp_size (stdoutput
))
1989 bss_seg
= subseg_new (".sbss", 1);
1990 seg_info (bss_seg
)->bss
= 1;
1991 #ifdef BFD_ASSEMBLER
1992 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1993 as_warn (_("error setting flags for \".sbss\": %s"),
1994 bfd_errmsg (bfd_get_error ()));
2002 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
2004 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
2006 record_alignment (bss_seg
, align
);
2014 if (*input_line_pointer
!= ',')
2016 as_bad (_("Expected comma after size"));
2017 ignore_rest_of_line ();
2021 input_line_pointer
++;
2024 if (*input_line_pointer
== '\n')
2026 as_bad (_("Missing alignment"));
2030 align
= get_absolute_expression ();
2034 /* Convert to a power of 2. */
2039 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2042 as_bad (_("Alignment not a power of 2"));
2047 if (align
> max_alignment
)
2049 align
= max_alignment
;
2050 as_warn (_("Alignment too large: %d. assumed."), align
);
2055 as_warn (_("Alignment negative. 0 assumed."));
2058 record_alignment (bss_seg
, align
);
2062 /* Assume some objects may require alignment on some systems. */
2063 #if defined (TC_ALPHA) && ! defined (VMS)
2066 align
= ffs (temp
) - 1;
2067 if (temp
% (1 << align
))
2074 symbolP
= symbol_find_or_make (name
);
2078 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2079 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2080 #ifdef BFD_ASSEMBLER
2081 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2082 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2084 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2087 (S_GET_SEGMENT (symbolP
) == bss_seg
2088 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2092 subseg_set (bss_seg
, 1);
2095 frag_align (align
, 0, 0);
2097 /* Detach from old frag. */
2098 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2099 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2101 symbol_set_frag (symbolP
, frag_now
);
2102 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2103 (offsetT
) temp
, (char *) 0);
2106 S_SET_SEGMENT (symbolP
, bss_seg
);
2109 /* The symbol may already have been created with a preceding
2110 ".globl" directive -- be careful not to step on storage class
2111 in that case. Otherwise, set it to static. */
2112 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2114 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2116 #endif /* OBJ_COFF */
2119 S_SET_SIZE (symbolP
, temp
);
2123 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
2124 S_GET_NAME (symbolP
));
2126 subseg_set (current_seg
, current_subseg
);
2128 demand_empty_rest_of_line ();
2132 s_lcomm (needs_align
)
2135 s_lcomm_internal (needs_align
, 0);
2139 s_lcomm_bytes (needs_align
)
2142 s_lcomm_internal (needs_align
, 1);
2147 int ignore ATTRIBUTE_UNUSED
;
2149 register char *name
;
2153 register symbolS
*symbolP
;
2155 /* We permit ANY defined expression: BSD4.2 demands constants. */
2156 name
= input_line_pointer
;
2157 c
= get_symbol_end ();
2158 p
= input_line_pointer
;
2162 if (*input_line_pointer
!= ',')
2165 as_bad (_("Expected comma after name \"%s\""), name
);
2167 ignore_rest_of_line ();
2171 input_line_pointer
++;
2174 if (exp
.X_op
!= O_constant
2175 && exp
.X_op
!= O_register
)
2177 as_bad (_("bad expression"));
2178 ignore_rest_of_line ();
2183 symbolP
= symbol_find_or_make (name
);
2185 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2186 symbolP->sy_desc == 0) out of this test because coff doesn't have
2187 those fields, and I can't see when they'd ever be tripped. I
2188 don't think I understand why they were here so I may have
2189 introduced a bug. As recently as 1.37 didn't have this test
2190 anyway. xoxorich. */
2192 if (S_GET_SEGMENT (symbolP
) == undefined_section
2193 && S_GET_VALUE (symbolP
) == 0)
2195 /* The name might be an undefined .global symbol; be sure to
2196 keep the "external" bit. */
2197 S_SET_SEGMENT (symbolP
,
2198 (exp
.X_op
== O_constant
2201 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2205 as_bad (_("Symbol %s already defined"), name
);
2209 demand_empty_rest_of_line ();
2212 /* Read a line into an sb. */
2218 char quote1
, quote2
, inquote
;
2220 if (input_line_pointer
[-1] == '\n')
2221 bump_line_counters ();
2223 if (input_line_pointer
>= buffer_limit
)
2225 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2226 if (buffer_limit
== 0)
2230 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2231 code needs to be changed. */
2240 #ifdef LEX_IS_STRINGQUOTE
2246 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2247 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2249 if (inquote
== *input_line_pointer
)
2251 else if (inquote
== '\0')
2253 if (*input_line_pointer
== quote1
)
2255 else if (*input_line_pointer
== quote2
)
2259 sb_add_char (line
, *input_line_pointer
++);
2262 while (input_line_pointer
< buffer_limit
2263 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2265 if (input_line_pointer
[-1] == '\n')
2266 bump_line_counters ();
2267 ++input_line_pointer
;
2273 /* Define a macro. This is an interface to macro.c, which is shared
2274 between gas and gasp. */
2278 int ignore ATTRIBUTE_UNUSED
;
2287 as_where (&file
, &line
);
2290 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2291 sb_add_char (&s
, *input_line_pointer
++);
2294 if (line_label
!= NULL
)
2295 sb_add_string (&label
, S_GET_NAME (line_label
));
2297 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2299 as_bad_where (file
, line
, "%s", err
);
2302 if (line_label
!= NULL
)
2304 S_SET_SEGMENT (line_label
, undefined_section
);
2305 S_SET_VALUE (line_label
, 0);
2306 symbol_set_frag (line_label
, &zero_address_frag
);
2309 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2310 && hash_find (po_hash
, name
) != NULL
)
2313 && hash_find (po_hash
, name
+ 1) != NULL
))
2314 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2321 /* Handle the .mexit pseudo-op, which immediately exits a macro
2326 int ignore ATTRIBUTE_UNUSED
;
2328 cond_exit_macro (macro_nest
);
2329 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2332 /* Switch in and out of MRI mode. */
2336 int ignore ATTRIBUTE_UNUSED
;
2340 on
= get_absolute_expression ();
2341 old_flag
= flag_mri
;
2359 /* Operator precedence changes in m68k MRI mode, so we need to
2360 update the operator rankings. */
2361 expr_set_precedence ();
2363 #ifdef MRI_MODE_CHANGE
2365 MRI_MODE_CHANGE (on
);
2368 demand_empty_rest_of_line ();
2371 /* Handle changing the location counter. */
2374 do_org (segment
, exp
, fill
)
2379 if (segment
!= now_seg
&& segment
!= absolute_section
)
2380 as_bad (_("invalid segment \"%s\"; segment \"%s\" assumed"),
2381 segment_name (segment
), segment_name (now_seg
));
2383 if (now_seg
== absolute_section
)
2386 as_warn (_("ignoring fill value in absolute section"));
2387 if (exp
->X_op
!= O_constant
)
2389 as_bad (_("only constant offsets supported in absolute section"));
2390 exp
->X_add_number
= 0;
2392 abs_section_offset
= exp
->X_add_number
;
2398 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
->X_add_symbol
,
2399 exp
->X_add_number
* OCTETS_PER_BYTE
, (char *) NULL
);
2406 int ignore ATTRIBUTE_UNUSED
;
2408 register segT segment
;
2410 register long temp_fill
;
2412 #ifdef md_flush_pending_output
2413 md_flush_pending_output ();
2416 /* The m68k MRI assembler has a different meaning for .org. It
2417 means to create an absolute section at a given address. We can't
2418 support that--use a linker script instead. */
2421 as_bad (_("MRI style ORG pseudo-op not supported"));
2422 ignore_rest_of_line ();
2426 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2427 thing as a sub-segment-relative origin. Any absolute origin is
2428 given a warning, then assumed to be segment-relative. Any
2429 segmented origin expression ("foo+42") had better be in the right
2430 segment or the .org is ignored.
2432 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2433 we never know sub-segment sizes when we are reading code. BSD
2434 will crash trying to emit negative numbers of filler bytes in
2435 certain .orgs. We don't crash, but see as-write for that code.
2437 Don't make frag if need_pass_2==1. */
2438 segment
= get_known_segmented_expression (&exp
);
2439 if (*input_line_pointer
== ',')
2441 input_line_pointer
++;
2442 temp_fill
= get_absolute_expression ();
2448 do_org (segment
, &exp
, temp_fill
);
2450 demand_empty_rest_of_line ();
2453 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2454 called by the obj-format routine which handles section changing
2455 when in MRI mode. It will create a new section, and return it. It
2456 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2457 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2458 flags will be set in the section. */
2462 char *type ATTRIBUTE_UNUSED
;
2472 name
= input_line_pointer
;
2473 if (!isdigit ((unsigned char) *name
))
2474 c
= get_symbol_end ();
2479 ++input_line_pointer
;
2481 while (isdigit ((unsigned char) *input_line_pointer
));
2483 c
= *input_line_pointer
;
2484 *input_line_pointer
= '\0';
2487 name
= xstrdup (name
);
2489 *input_line_pointer
= c
;
2491 seg
= subseg_new (name
, 0);
2493 if (*input_line_pointer
== ',')
2497 ++input_line_pointer
;
2498 align
= get_absolute_expression ();
2499 record_alignment (seg
, align
);
2503 if (*input_line_pointer
== ',')
2505 c
= *++input_line_pointer
;
2506 c
= toupper ((unsigned char) c
);
2507 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2510 as_bad (_("unrecognized section type"));
2511 ++input_line_pointer
;
2513 #ifdef BFD_ASSEMBLER
2517 flags
= SEC_NO_FLAGS
;
2519 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2520 else if (*type
== 'D' || *type
== 'M')
2521 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2522 else if (*type
== 'R')
2523 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2524 if (flags
!= SEC_NO_FLAGS
)
2526 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2527 as_warn (_("error setting flags for \"%s\": %s"),
2528 bfd_section_name (stdoutput
, seg
),
2529 bfd_errmsg (bfd_get_error ()));
2535 /* Ignore the HP type. */
2536 if (*input_line_pointer
== ',')
2537 input_line_pointer
+= 2;
2539 demand_empty_rest_of_line ();
2541 #else /* ! TC_M68K */
2550 name
= input_line_pointer
;
2551 c
= get_symbol_end ();
2553 name
= xstrdup (name
);
2555 *input_line_pointer
= c
;
2557 seg
= subseg_new (name
, 0);
2559 if (*input_line_pointer
!= ',')
2565 ++input_line_pointer
;
2567 sectype
= input_line_pointer
;
2568 c
= get_symbol_end ();
2569 if (*sectype
== '\0')
2571 else if (strcasecmp (sectype
, "text") == 0)
2573 else if (strcasecmp (sectype
, "data") == 0)
2575 else if (strcasecmp (sectype
, "romdata") == 0)
2578 as_warn (_("unrecognized section type `%s'"), sectype
);
2579 *input_line_pointer
= c
;
2582 if (*input_line_pointer
== ',')
2586 ++input_line_pointer
;
2588 seccmd
= input_line_pointer
;
2589 c
= get_symbol_end ();
2590 if (strcasecmp (seccmd
, "absolute") == 0)
2592 as_bad (_("absolute sections are not supported"));
2593 *input_line_pointer
= c
;
2594 ignore_rest_of_line ();
2597 else if (strcasecmp (seccmd
, "align") == 0)
2601 *input_line_pointer
= c
;
2602 align
= get_absolute_expression ();
2603 record_alignment (seg
, align
);
2607 as_warn (_("unrecognized section command `%s'"), seccmd
);
2608 *input_line_pointer
= c
;
2612 demand_empty_rest_of_line ();
2614 #else /* ! TC_I960 */
2615 /* The MRI assembler seems to use different forms of .sect for
2616 different targets. */
2617 as_bad ("MRI mode not supported for this target");
2618 ignore_rest_of_line ();
2619 #endif /* ! TC_I960 */
2620 #endif /* ! TC_M68K */
2623 /* Handle the .print pseudo-op. */
2627 int ignore ATTRIBUTE_UNUSED
;
2632 s
= demand_copy_C_string (&len
);
2634 demand_empty_rest_of_line ();
2637 /* Handle the .purgem pseudo-op. */
2641 int ignore ATTRIBUTE_UNUSED
;
2643 if (is_it_end_of_statement ())
2645 demand_empty_rest_of_line ();
2655 name
= input_line_pointer
;
2656 c
= get_symbol_end ();
2657 delete_macro (name
);
2658 *input_line_pointer
= c
;
2661 while (*input_line_pointer
++ == ',');
2663 --input_line_pointer
;
2664 demand_empty_rest_of_line ();
2667 /* Handle the .rept pseudo-op. */
2671 int ignore ATTRIBUTE_UNUSED
;
2675 count
= get_absolute_expression ();
2677 do_repeat (count
, "REPT", "ENDR");
2680 /* This function provides a generic repeat block implementation. It allows
2681 different directives to be used as the start/end keys. */
2684 do_repeat (count
, start
, end
)
2693 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2695 as_bad (_("%s without %s"), start
, end
);
2701 sb_add_sb (&many
, &one
);
2705 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2707 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2710 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2711 input buffers to skip. Assumes that conditionals preceding the loop end
2712 are properly nested.
2714 This function makes it easier to implement a premature "break" out of the
2715 loop. The EXTRA arg accounts for other buffers we might have inserted,
2716 such as line substitutions. */
2722 cond_exit_macro (macro_nest
);
2723 while (extra
-- >= 0)
2724 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2727 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2728 this is .equiv, and it is an error if the symbol is already
2735 register char *name
;
2736 register char delim
;
2737 register char *end_name
;
2738 register symbolS
*symbolP
;
2740 /* Especial apologies for the random logic:
2741 this just grew, and could be parsed much more simply!
2743 name
= input_line_pointer
;
2744 delim
= get_symbol_end ();
2745 end_name
= input_line_pointer
;
2749 if (*input_line_pointer
!= ',')
2752 as_bad (_("Expected comma after name \"%s\""), name
);
2754 ignore_rest_of_line ();
2758 input_line_pointer
++;
2761 if (name
[0] == '.' && name
[1] == '\0')
2763 /* Turn '. = mumble' into a .org mumble. */
2764 register segT segment
;
2767 segment
= get_known_segmented_expression (&exp
);
2770 do_org (segment
, &exp
, 0);
2776 if ((symbolP
= symbol_find (name
)) == NULL
2777 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2780 /* When doing symbol listings, play games with dummy fragments living
2781 outside the normal fragment chain to record the file and line info
2783 if (listing
& LISTING_SYMBOLS
)
2785 extern struct list_info_struct
*listing_tail
;
2786 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2787 memset (dummy_frag
, 0, sizeof (fragS
));
2788 dummy_frag
->fr_type
= rs_fill
;
2789 dummy_frag
->line
= listing_tail
;
2790 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2791 dummy_frag
->fr_symbol
= symbolP
;
2795 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2798 /* "set" symbols are local unless otherwise specified. */
2799 SF_SET_LOCAL (symbolP
);
2800 #endif /* OBJ_COFF */
2803 symbol_table_insert (symbolP
);
2808 && S_IS_DEFINED (symbolP
)
2809 && S_GET_SEGMENT (symbolP
) != reg_section
)
2810 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
2812 pseudo_set (symbolP
);
2813 demand_empty_rest_of_line ();
2827 #ifdef md_flush_pending_output
2828 md_flush_pending_output ();
2832 stop
= mri_comment_field (&stopc
);
2834 /* In m68k MRI mode, we need to align to a word boundary, unless
2836 if (flag_m68k_mri
&& mult
> 1)
2838 if (now_seg
== absolute_section
)
2840 abs_section_offset
+= abs_section_offset
& 1;
2841 if (line_label
!= NULL
)
2842 S_SET_VALUE (line_label
, abs_section_offset
);
2844 else if (mri_common_symbol
!= NULL
)
2848 val
= S_GET_VALUE (mri_common_symbol
);
2851 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2852 if (line_label
!= NULL
)
2854 expressionS
*symexp
;
2856 symexp
= symbol_get_value_expression (line_label
);
2857 know (symexp
->X_op
== O_symbol
);
2858 know (symexp
->X_add_symbol
== mri_common_symbol
);
2859 symexp
->X_add_number
+= 1;
2865 do_align (1, (char *) NULL
, 0, 0);
2866 if (line_label
!= NULL
)
2868 symbol_set_frag (line_label
, frag_now
);
2869 S_SET_VALUE (line_label
, frag_now_fix ());
2879 if (*input_line_pointer
== ',')
2881 ++input_line_pointer
;
2886 val
.X_op
= O_constant
;
2887 val
.X_add_number
= 0;
2890 if (val
.X_op
!= O_constant
2891 || val
.X_add_number
< - 0x80
2892 || val
.X_add_number
> 0xff
2893 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2895 if (exp
.X_op
!= O_constant
)
2896 as_bad (_("Unsupported variable size or fill value"));
2903 bytes
= mult
* exp
.X_add_number
;
2904 for (i
= 0; i
< exp
.X_add_number
; i
++)
2905 emit_expr (&val
, mult
);
2910 if (exp
.X_op
== O_constant
)
2914 repeat
= exp
.X_add_number
;
2921 as_warn (_(".space repeat count is zero, ignored"));
2922 else if (repeat
< 0)
2923 as_warn (_(".space repeat count is negative, ignored"));
2927 /* If we are in the absolute section, just bump the offset. */
2928 if (now_seg
== absolute_section
)
2930 abs_section_offset
+= repeat
;
2934 /* If we are secretly in an MRI common section, then
2935 creating space just increases the size of the common
2937 if (mri_common_symbol
!= NULL
)
2939 S_SET_VALUE (mri_common_symbol
,
2940 S_GET_VALUE (mri_common_symbol
) + repeat
);
2945 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2946 (offsetT
) repeat
, (char *) 0);
2950 if (now_seg
== absolute_section
)
2952 as_bad (_("space allocation too complex in absolute section"));
2953 subseg_set (text_section
, 0);
2956 if (mri_common_symbol
!= NULL
)
2958 as_bad (_("space allocation too complex in common section"));
2959 mri_common_symbol
= NULL
;
2963 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2964 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2968 *p
= val
.X_add_number
;
2973 /* In MRI mode, after an odd number of bytes, we must align to an
2974 even word boundary, unless the next instruction is a dc.b, ds.b
2976 if (flag_mri
&& (bytes
& 1) != 0)
2977 mri_pending_align
= 1;
2979 demand_empty_rest_of_line ();
2982 mri_comment_end (stop
, stopc
);
2985 /* This is like s_space, but the value is a floating point number with
2986 the given precision. This is for the MRI dcb.s pseudo-op and
2990 s_float_space (float_type
)
2995 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3000 stop
= mri_comment_field (&stopc
);
3002 count
= get_absolute_expression ();
3005 if (*input_line_pointer
!= ',')
3007 as_bad (_("missing value"));
3008 ignore_rest_of_line ();
3010 mri_comment_end (stop
, stopc
);
3014 ++input_line_pointer
;
3018 /* Skip any 0{letter} that may be present. Don't even check if the
3019 * letter is legal. */
3020 if (input_line_pointer
[0] == '0'
3021 && isalpha ((unsigned char) input_line_pointer
[1]))
3022 input_line_pointer
+= 2;
3024 /* Accept :xxxx, where the x's are hex digits, for a floating point
3025 with the exact digits specified. */
3026 if (input_line_pointer
[0] == ':')
3028 flen
= hex_float (float_type
, temp
);
3031 ignore_rest_of_line ();
3033 mri_comment_end (stop
, stopc
);
3041 err
= md_atof (float_type
, temp
, &flen
);
3042 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3046 as_bad (_("Bad floating literal: %s"), err
);
3047 ignore_rest_of_line ();
3049 mri_comment_end (stop
, stopc
);
3054 while (--count
>= 0)
3058 p
= frag_more (flen
);
3059 memcpy (p
, temp
, (unsigned int) flen
);
3062 demand_empty_rest_of_line ();
3065 mri_comment_end (stop
, stopc
);
3068 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3072 int ignore ATTRIBUTE_UNUSED
;
3078 stop
= mri_comment_field (&stopc
);
3079 abs_section_offset
= get_absolute_expression ();
3080 subseg_set (absolute_section
, 0);
3081 demand_empty_rest_of_line ();
3083 mri_comment_end (stop
, stopc
);
3088 int ignore ATTRIBUTE_UNUSED
;
3092 temp
= get_absolute_expression ();
3093 subseg_set (text_section
, (subsegT
) temp
);
3094 demand_empty_rest_of_line ();
3096 const_flag
&= ~IN_DEFAULT_SECTION
;
3101 demand_empty_rest_of_line ()
3104 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3105 input_line_pointer
++;
3107 ignore_rest_of_line ();
3109 /* Return having already swallowed end-of-line. */
3113 ignore_rest_of_line ()
3115 /* For suspect lines: gives warning. */
3116 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3118 if (isprint ((unsigned char) *input_line_pointer
))
3119 as_bad (_("Rest of line ignored. First ignored character is `%c'."),
3120 *input_line_pointer
);
3122 as_bad (_("Rest of line ignored. First ignored character valued 0x%x."),
3123 *input_line_pointer
);
3125 while (input_line_pointer
< buffer_limit
3126 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3127 input_line_pointer
++;
3130 input_line_pointer
++;
3132 /* Return pointing just after end-of-line. */
3133 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3137 discard_rest_of_line ()
3139 while (input_line_pointer
< buffer_limit
3140 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3141 input_line_pointer
++;
3143 input_line_pointer
++;
3145 /* Return pointing just after end-of-line. */
3146 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3149 /* In: Pointer to a symbol.
3150 Input_line_pointer->expression.
3152 Out: Input_line_pointer->just after any whitespace after expression.
3153 Tried to set symbol to value of expression.
3154 Will change symbols type, value, and frag; */
3157 pseudo_set (symbolP
)
3161 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3163 #endif /* OBJ_AOUT or OBJ_BOUT */
3165 know (symbolP
); /* NULL pointer is logic error. */
3166 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3167 ext
= S_IS_EXTERNAL (symbolP
);
3168 #endif /* OBJ_AOUT or OBJ_BOUT */
3170 (void) expression (&exp
);
3172 if (exp
.X_op
== O_illegal
)
3173 as_bad (_("illegal expression; zero assumed"));
3174 else if (exp
.X_op
== O_absent
)
3175 as_bad (_("missing expression; zero assumed"));
3176 else if (exp
.X_op
== O_big
)
3178 if (exp
.X_add_number
> 0)
3179 as_bad (_("bignum invalid; zero assumed"));
3181 as_bad (_("floating point number invalid; zero assumed"));
3183 else if (exp
.X_op
== O_subtract
3184 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3185 == S_GET_SEGMENT (exp
.X_op_symbol
))
3186 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3187 && (symbol_get_frag (exp
.X_add_symbol
)
3188 == symbol_get_frag (exp
.X_op_symbol
)))
3190 exp
.X_op
= O_constant
;
3191 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3192 - S_GET_VALUE (exp
.X_op_symbol
));
3200 exp
.X_add_number
= 0;
3203 S_SET_SEGMENT (symbolP
, absolute_section
);
3204 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3206 S_SET_EXTERNAL (symbolP
);
3208 S_CLEAR_EXTERNAL (symbolP
);
3209 #endif /* OBJ_AOUT or OBJ_BOUT */
3210 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3211 if (exp
.X_op
!= O_constant
)
3212 symbol_set_frag (symbolP
, &zero_address_frag
);
3216 S_SET_SEGMENT (symbolP
, reg_section
);
3217 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3218 symbol_set_frag (symbolP
, &zero_address_frag
);
3222 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3223 || exp
.X_add_number
!= 0)
3224 symbol_set_value_expression (symbolP
, &exp
);
3225 else if (symbol_section_p (symbolP
))
3226 as_bad ("invalid attempt to set value of section symbol");
3229 symbolS
*s
= exp
.X_add_symbol
;
3231 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3232 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3234 S_SET_EXTERNAL (symbolP
);
3236 S_CLEAR_EXTERNAL (symbolP
);
3237 #endif /* OBJ_AOUT or OBJ_BOUT */
3238 S_SET_VALUE (symbolP
,
3239 exp
.X_add_number
+ S_GET_VALUE (s
));
3240 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3241 copy_symbol_attributes (symbolP
, s
);
3246 /* The value is some complex expression.
3247 FIXME: Should we set the segment to anything? */
3248 symbol_set_value_expression (symbolP
, &exp
);
3255 CONStruct more frag of .bytes, or .words etc.
3256 Should need_pass_2 be 1 then emit no frag(s).
3257 This understands EXPRESSIONS.
3261 This has a split personality. We use expression() to read the
3262 value. We can detect if the value won't fit in a byte or word.
3263 But we can't detect if expression() discarded significant digits
3264 in the case of a long. Not worth the crocks required to fix it. */
3266 /* Select a parser for cons expressions. */
3268 /* Some targets need to parse the expression in various fancy ways.
3269 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3270 (for example, the HPPA does this). Otherwise, you can define
3271 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3272 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3273 are defined, which is the normal case, then only simple expressions
3278 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3281 #ifndef TC_PARSE_CONS_EXPRESSION
3282 #ifdef BITFIELD_CONS_EXPRESSIONS
3283 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3285 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3287 #ifdef REPEAT_CONS_EXPRESSIONS
3288 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3290 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3293 /* If we haven't gotten one yet, just call expression. */
3294 #ifndef TC_PARSE_CONS_EXPRESSION
3295 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3299 /* Worker to do .byte etc statements.
3300 Clobbers input_line_pointer and checks end-of-line. */
3303 cons_worker (nbytes
, rva
)
3304 register int nbytes
; /* 1=.byte, 2=.word, 4=.long. */
3312 #ifdef md_flush_pending_output
3313 md_flush_pending_output ();
3317 stop
= mri_comment_field (&stopc
);
3319 if (is_it_end_of_statement ())
3321 demand_empty_rest_of_line ();
3323 mri_comment_end (stop
, stopc
);
3327 #ifdef md_cons_align
3328 md_cons_align (nbytes
);
3336 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3339 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3343 if (exp
.X_op
== O_symbol
)
3344 exp
.X_op
= O_symbol_rva
;
3346 as_fatal (_("rva without symbol"));
3348 emit_expr (&exp
, (unsigned int) nbytes
);
3351 while (*input_line_pointer
++ == ',');
3353 /* In MRI mode, after an odd number of bytes, we must align to an
3354 even word boundary, unless the next instruction is a dc.b, ds.b
3356 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3357 mri_pending_align
= 1;
3359 input_line_pointer
--; /* Put terminator back into stream. */
3361 demand_empty_rest_of_line ();
3364 mri_comment_end (stop
, stopc
);
3371 cons_worker (size
, 0);
3378 cons_worker (size
, 1);
3381 /* Put the contents of expression EXP into the object file using
3382 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3385 emit_expr (exp
, nbytes
)
3387 unsigned int nbytes
;
3391 valueT extra_digit
= 0;
3393 /* Don't do anything if we are going to make another pass. */
3399 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3400 appear as a four byte positive constant in the .line section,
3401 followed by a 2 byte 0xffff. Look for that case here. */
3403 static int dwarf_line
= -1;
3405 if (strcmp (segment_name (now_seg
), ".line") != 0)
3407 else if (dwarf_line
>= 0
3409 && exp
->X_op
== O_constant
3410 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3411 listing_source_line ((unsigned int) dwarf_line
);
3412 else if (nbytes
== 4
3413 && exp
->X_op
== O_constant
3414 && exp
->X_add_number
>= 0)
3415 dwarf_line
= exp
->X_add_number
;
3420 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3421 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3422 AT_sibling (0x12) followed by a four byte address of the sibling
3423 followed by a 2 byte AT_name (0x38) followed by the name of the
3424 file. We look for that case here. */
3426 static int dwarf_file
= 0;
3428 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3430 else if (dwarf_file
== 0
3432 && exp
->X_op
== O_constant
3433 && exp
->X_add_number
== 0x11)
3435 else if (dwarf_file
== 1
3437 && exp
->X_op
== O_constant
3438 && exp
->X_add_number
== 0x12)
3440 else if (dwarf_file
== 2
3443 else if (dwarf_file
== 3
3445 && exp
->X_op
== O_constant
3446 && exp
->X_add_number
== 0x38)
3451 /* The variable dwarf_file_string tells stringer that the string
3452 may be the name of the source file. */
3453 if (dwarf_file
== 4)
3454 dwarf_file_string
= 1;
3456 dwarf_file_string
= 0;
3461 if (check_eh_frame (exp
, &nbytes
))
3466 /* Allow `.word 0' in the absolute section. */
3467 if (now_seg
== absolute_section
)
3469 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3470 as_bad (_("attempt to store value in absolute section"));
3471 abs_section_offset
+= nbytes
;
3475 /* Handle a negative bignum. */
3477 && exp
->X_add_number
== 0
3478 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3479 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3482 unsigned long carry
;
3484 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3486 /* Negate the bignum: one's complement each digit and add 1. */
3488 for (i
= 0; i
< exp
->X_add_number
; i
++)
3492 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3495 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3496 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3499 /* We can ignore any carry out, because it will be handled by
3500 extra_digit if it is needed. */
3502 extra_digit
= (valueT
) -1;
3506 if (op
== O_absent
|| op
== O_illegal
)
3508 as_warn (_("zero assumed for missing expression"));
3509 exp
->X_add_number
= 0;
3512 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3514 as_bad (_("floating point number invalid; zero assumed"));
3515 exp
->X_add_number
= 0;
3518 else if (op
== O_register
)
3520 as_warn (_("register value used as expression"));
3524 p
= frag_more ((int) nbytes
);
3526 #ifndef WORKING_DOT_WORD
3527 /* If we have the difference of two symbols in a word, save it on
3528 the broken_words list. See the code in write.c. */
3529 if (op
== O_subtract
&& nbytes
== 2)
3531 struct broken_word
*x
;
3533 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3534 x
->next_broken_word
= broken_words
;
3537 x
->subseg
= now_subseg
;
3539 x
->word_goes_here
= p
;
3541 x
->add
= exp
->X_add_symbol
;
3542 x
->sub
= exp
->X_op_symbol
;
3543 x
->addnum
= exp
->X_add_number
;
3550 /* If we have an integer, but the number of bytes is too large to
3551 pass to md_number_to_chars, handle it as a bignum. */
3552 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3557 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3558 extra_digit
= (valueT
) -1;
3559 val
= (valueT
) exp
->X_add_number
;
3563 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3564 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3568 op
= exp
->X_op
= O_big
;
3569 exp
->X_add_number
= gencnt
;
3572 if (op
== O_constant
)
3574 register valueT get
;
3575 register valueT use
;
3576 register valueT mask
;
3578 register valueT unmask
;
3580 /* JF << of >= number of bits in the object is undefined. In
3581 particular SPARC (Sun 4) has problems. */
3582 if (nbytes
>= sizeof (valueT
))
3585 if (nbytes
> sizeof (valueT
))
3588 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3592 /* Don't store these bits. */
3593 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3594 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3597 unmask
= ~mask
; /* Do store these bits. */
3600 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3601 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3604 get
= exp
->X_add_number
;
3606 if ((get
& mask
) != 0
3607 && ((get
& mask
) != mask
3608 || (get
& hibit
) == 0))
3609 { /* Leading bits contain both 0s & 1s. */
3610 as_warn (_("Value 0x%lx truncated to 0x%lx."),
3611 (unsigned long) get
, (unsigned long) use
);
3613 /* Put bytes in right order. */
3614 md_number_to_chars (p
, use
, (int) nbytes
);
3616 else if (op
== O_big
)
3619 LITTLENUM_TYPE
*nums
;
3621 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3623 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3626 as_warn (_("Bignum truncated to %d bytes"), nbytes
);
3630 if (target_big_endian
)
3632 while (nbytes
> size
)
3634 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3635 nbytes
-= CHARS_PER_LITTLENUM
;
3636 p
+= CHARS_PER_LITTLENUM
;
3639 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3643 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3644 size
-= CHARS_PER_LITTLENUM
;
3645 p
+= CHARS_PER_LITTLENUM
;
3650 nums
= generic_bignum
;
3653 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3655 size
-= CHARS_PER_LITTLENUM
;
3656 p
+= CHARS_PER_LITTLENUM
;
3657 nbytes
-= CHARS_PER_LITTLENUM
;
3662 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3663 nbytes
-= CHARS_PER_LITTLENUM
;
3664 p
+= CHARS_PER_LITTLENUM
;
3670 memset (p
, 0, nbytes
);
3672 /* Now we need to generate a fixS to record the symbol value.
3673 This is easy for BFD. For other targets it can be more
3674 complex. For very complex cases (currently, the HPPA and
3675 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3676 want. For simpler cases, you can define TC_CONS_RELOC to be
3677 the name of the reloc code that should be stored in the fixS.
3678 If neither is defined, the code uses NO_RELOC if it is
3679 defined, and otherwise uses 0. */
3681 #ifdef BFD_ASSEMBLER
3682 #ifdef TC_CONS_FIX_NEW
3683 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3686 bfd_reloc_code_real_type r
;
3703 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3707 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3712 #ifdef TC_CONS_FIX_NEW
3713 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3715 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3716 it is defined, otherwise use NO_RELOC if it is defined,
3718 #ifndef TC_CONS_RELOC
3720 #define TC_CONS_RELOC NO_RELOC
3722 #define TC_CONS_RELOC 0
3725 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3727 #endif /* TC_CONS_FIX_NEW */
3728 #endif /* BFD_ASSEMBLER */
3732 #ifdef BITFIELD_CONS_EXPRESSIONS
3734 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3735 w:x,y:z, where w and y are bitwidths and x and y are values. They
3736 then pack them all together. We do a little better in that we allow
3737 them in words, longs, etc. and we'll pack them in target byte order
3740 The rules are: pack least significat bit first, if a field doesn't
3741 entirely fit, put it in the next unit. Overflowing the bitfield is
3742 explicitly *not* even a warning. The bitwidth should be considered
3745 To use this function the tc-XXX.h file should define
3746 BITFIELD_CONS_EXPRESSIONS. */
3749 parse_bitfield_cons (exp
, nbytes
)
3751 unsigned int nbytes
;
3753 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3754 char *hold
= input_line_pointer
;
3756 (void) expression (exp
);
3758 if (*input_line_pointer
== ':')
3765 unsigned long width
;
3767 if (*input_line_pointer
!= ':')
3769 input_line_pointer
= hold
;
3771 } /* Next piece is not a bitfield. */
3773 /* In the general case, we can't allow
3774 full expressions with symbol
3775 differences and such. The relocation
3776 entries for symbols not defined in this
3777 assembly would require arbitrary field
3778 widths, positions, and masks which most
3779 of our current object formats don't
3782 In the specific case where a symbol
3783 *is* defined in this assembly, we
3784 *could* build fixups and track it, but
3785 this could lead to confusion for the
3786 backends. I'm lazy. I'll take any
3787 SEG_ABSOLUTE. I think that means that
3788 you can use a previous .set or
3789 .equ type symbol. xoxorich. */
3791 if (exp
->X_op
== O_absent
)
3793 as_warn (_("using a bit field width of zero"));
3794 exp
->X_add_number
= 0;
3795 exp
->X_op
= O_constant
;
3796 } /* Implied zero width bitfield. */
3798 if (exp
->X_op
!= O_constant
)
3800 *input_line_pointer
= '\0';
3801 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3802 *input_line_pointer
= ':';
3803 demand_empty_rest_of_line ();
3805 } /* Too complex. */
3807 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3809 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3810 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3811 width
= BITS_PER_CHAR
* nbytes
;
3814 if (width
> bits_available
)
3816 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3817 input_line_pointer
= hold
;
3818 exp
->X_add_number
= value
;
3822 hold
= ++input_line_pointer
; /* skip ':' */
3824 (void) expression (exp
);
3825 if (exp
->X_op
!= O_constant
)
3827 char cache
= *input_line_pointer
;
3829 *input_line_pointer
= '\0';
3830 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3831 *input_line_pointer
= cache
;
3832 demand_empty_rest_of_line ();
3834 } /* Too complex. */
3836 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3837 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3839 if ((bits_available
-= width
) == 0
3840 || is_it_end_of_statement ()
3841 || *input_line_pointer
!= ',')
3844 } /* All the bitfields we're gonna get. */
3846 hold
= ++input_line_pointer
;
3847 (void) expression (exp
);
3850 exp
->X_add_number
= value
;
3851 exp
->X_op
= O_constant
;
3852 exp
->X_unsigned
= 1;
3856 #endif /* BITFIELD_CONS_EXPRESSIONS */
3858 /* Handle an MRI style string expression. */
3862 parse_mri_cons (exp
, nbytes
)
3864 unsigned int nbytes
;
3866 if (*input_line_pointer
!= '\''
3867 && (input_line_pointer
[1] != '\''
3868 || (*input_line_pointer
!= 'A'
3869 && *input_line_pointer
!= 'E')))
3870 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3874 unsigned int result
= 0;
3876 /* An MRI style string. Cut into as many bytes as will fit into
3877 a nbyte chunk, left justify if necessary, and separate with
3878 commas so we can try again later. */
3879 if (*input_line_pointer
== 'A')
3880 ++input_line_pointer
;
3881 else if (*input_line_pointer
== 'E')
3883 as_bad (_("EBCDIC constants are not supported"));
3884 ++input_line_pointer
;
3887 input_line_pointer
++;
3888 for (scan
= 0; scan
< nbytes
; scan
++)
3890 if (*input_line_pointer
== '\'')
3892 if (input_line_pointer
[1] == '\'')
3894 input_line_pointer
++;
3899 result
= (result
<< 8) | (*input_line_pointer
++);
3903 while (scan
< nbytes
)
3909 /* Create correct expression. */
3910 exp
->X_op
= O_constant
;
3911 exp
->X_add_number
= result
;
3913 /* Fake it so that we can read the next char too. */
3914 if (input_line_pointer
[0] != '\'' ||
3915 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3917 input_line_pointer
-= 2;
3918 input_line_pointer
[0] = ',';
3919 input_line_pointer
[1] = '\'';
3922 input_line_pointer
++;
3925 #endif /* TC_M68K */
3927 #ifdef REPEAT_CONS_EXPRESSIONS
3929 /* Parse a repeat expression for cons. This is used by the MIPS
3930 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3931 object file COUNT times.
3933 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3936 parse_repeat_cons (exp
, nbytes
)
3938 unsigned int nbytes
;
3945 if (*input_line_pointer
!= ':')
3947 /* No repeat count. */
3951 ++input_line_pointer
;
3952 expression (&count
);
3953 if (count
.X_op
!= O_constant
3954 || count
.X_add_number
<= 0)
3956 as_warn (_("Unresolvable or nonpositive repeat count; using 1"));
3960 /* The cons function is going to output this expression once. So we
3961 output it count - 1 times. */
3962 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3963 emit_expr (exp
, nbytes
);
3966 #endif /* REPEAT_CONS_EXPRESSIONS */
3968 /* Parse a floating point number represented as a hex constant. This
3969 permits users to specify the exact bits they want in the floating
3973 hex_float (float_type
, bytes
)
4007 as_bad (_("Unknown floating type type '%c'"), float_type
);
4011 /* It would be nice if we could go through expression to parse the
4012 hex constant, but if we get a bignum it's a pain to sort it into
4013 the buffer correctly. */
4015 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4019 /* The MRI assembler accepts arbitrary underscores strewn about
4020 through the hex constant, so we ignore them as well. */
4021 if (*input_line_pointer
== '_')
4023 ++input_line_pointer
;
4029 as_warn (_("Floating point constant too large"));
4032 d
= hex_value (*input_line_pointer
) << 4;
4033 ++input_line_pointer
;
4034 while (*input_line_pointer
== '_')
4035 ++input_line_pointer
;
4036 if (hex_p (*input_line_pointer
))
4038 d
+= hex_value (*input_line_pointer
);
4039 ++input_line_pointer
;
4041 if (target_big_endian
)
4044 bytes
[length
- i
- 1] = d
;
4050 if (target_big_endian
)
4051 memset (bytes
+ i
, 0, length
- i
);
4053 memset (bytes
, 0, length
- i
);
4061 CONStruct some more frag chars of .floats .ffloats etc.
4062 Makes 0 or more new frags.
4063 If need_pass_2 == 1, no frags are emitted.
4064 This understands only floating literals, not expressions. Sorry.
4066 A floating constant is defined by atof_generic(), except it is preceded
4067 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4068 reading, I decided to be incompatible. This always tries to give you
4069 rounded bits to the precision of the pseudo-op. Former AS did premature
4070 truncatation, restored noisy bits instead of trailing 0s AND gave you
4071 a choice of 2 flavours of noise according to which of 2 floating-point
4072 scanners you directed AS to use.
4074 In: input_line_pointer->whitespace before, or '0' of flonum. */
4077 float_cons (float_type
)
4078 /* Clobbers input_line-pointer, checks end-of-line. */
4079 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4082 int length
; /* Number of chars in an object. */
4083 register char *err
; /* Error from scanning floating literal. */
4084 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4086 if (is_it_end_of_statement ())
4088 demand_empty_rest_of_line ();
4092 #ifdef md_flush_pending_output
4093 md_flush_pending_output ();
4098 /* input_line_pointer->1st char of a flonum (we hope!). */
4101 /* Skip any 0{letter} that may be present. Don't even check if the
4102 letter is legal. Someone may invent a "z" format and this routine
4103 has no use for such information. Lusers beware: you get
4104 diagnostics if your input is ill-conditioned. */
4105 if (input_line_pointer
[0] == '0'
4106 && isalpha ((unsigned char) input_line_pointer
[1]))
4107 input_line_pointer
+= 2;
4109 /* Accept :xxxx, where the x's are hex digits, for a floating
4110 point with the exact digits specified. */
4111 if (input_line_pointer
[0] == ':')
4113 ++input_line_pointer
;
4114 length
= hex_float (float_type
, temp
);
4117 ignore_rest_of_line ();
4123 err
= md_atof (float_type
, temp
, &length
);
4124 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4128 as_bad (_("Bad floating literal: %s"), err
);
4129 ignore_rest_of_line ();
4140 #ifdef REPEAT_CONS_EXPRESSIONS
4141 if (*input_line_pointer
== ':')
4143 expressionS count_exp
;
4145 ++input_line_pointer
;
4146 expression (&count_exp
);
4148 if (count_exp
.X_op
!= O_constant
4149 || count_exp
.X_add_number
<= 0)
4150 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4152 count
= count_exp
.X_add_number
;
4156 while (--count
>= 0)
4158 p
= frag_more (length
);
4159 memcpy (p
, temp
, (unsigned int) length
);
4164 while (*input_line_pointer
++ == ',');
4166 /* Put terminator back into stream. */
4167 --input_line_pointer
;
4168 demand_empty_rest_of_line ();
4171 /* Return the size of a LEB128 value. */
4174 sizeof_sleb128 (value
)
4177 register int size
= 0;
4178 register unsigned byte
;
4182 byte
= (value
& 0x7f);
4183 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4184 Fortunately, we can structure things so that the extra work reduces
4185 to a noop on systems that do things "properly". */
4186 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4189 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4190 || ((value
== -1) && ((byte
& 0x40) != 0))));
4196 sizeof_uleb128 (value
)
4199 register int size
= 0;
4200 register unsigned byte
;
4204 byte
= (value
& 0x7f);
4214 sizeof_leb128 (value
, sign
)
4219 return sizeof_sleb128 ((offsetT
) value
);
4221 return sizeof_uleb128 (value
);
4224 /* Output a LEB128 value. */
4227 output_sleb128 (p
, value
)
4231 register char *orig
= p
;
4236 unsigned byte
= (value
& 0x7f);
4238 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4239 Fortunately, we can structure things so that the extra work reduces
4240 to a noop on systems that do things "properly". */
4241 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4243 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4244 || ((value
== -1) && ((byte
& 0x40) != 0))));
4256 output_uleb128 (p
, value
)
4264 unsigned byte
= (value
& 0x7f);
4267 /* More bytes to follow. */
4278 output_leb128 (p
, value
, sign
)
4284 return output_sleb128 (p
, (offsetT
) value
);
4286 return output_uleb128 (p
, value
);
4289 /* Do the same for bignums. We combine sizeof with output here in that
4290 we don't output for NULL values of P. It isn't really as critical as
4291 for "normal" values that this be streamlined. */
4294 output_big_sleb128 (p
, bignum
, size
)
4296 LITTLENUM_TYPE
*bignum
;
4304 /* Strip leading sign extensions off the bignum. */
4305 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4310 if (loaded
< 7 && size
> 0)
4312 val
|= (*bignum
<< loaded
);
4313 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4324 if ((val
== 0 && (byte
& 0x40) == 0)
4325 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4326 && (byte
& 0x40) != 0))
4334 while (byte
& 0x80);
4340 output_big_uleb128 (p
, bignum
, size
)
4342 LITTLENUM_TYPE
*bignum
;
4350 /* Strip leading zeros off the bignum. */
4351 /* XXX: Is this needed? */
4352 while (size
> 0 && bignum
[size
- 1] == 0)
4357 if (loaded
< 7 && size
> 0)
4359 val
|= (*bignum
<< loaded
);
4360 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4369 if (size
> 0 || val
)
4376 while (byte
& 0x80);
4382 output_big_leb128 (p
, bignum
, size
, sign
)
4384 LITTLENUM_TYPE
*bignum
;
4388 return output_big_sleb128 (p
, bignum
, size
);
4390 return output_big_uleb128 (p
, bignum
, size
);
4393 /* Generate the appropriate fragments for a given expression to emit a
4397 emit_leb128_expr (exp
, sign
)
4401 operatorT op
= exp
->X_op
;
4403 if (op
== O_absent
|| op
== O_illegal
)
4405 as_warn (_("zero assumed for missing expression"));
4406 exp
->X_add_number
= 0;
4409 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4411 as_bad (_("floating point number invalid; zero assumed"));
4412 exp
->X_add_number
= 0;
4415 else if (op
== O_register
)
4417 as_warn (_("register value used as expression"));
4421 if (op
== O_constant
)
4423 /* If we've got a constant, emit the thing directly right now. */
4425 valueT value
= exp
->X_add_number
;
4429 size
= sizeof_leb128 (value
, sign
);
4430 p
= frag_more (size
);
4431 output_leb128 (p
, value
, sign
);
4433 else if (op
== O_big
)
4435 /* O_big is a different sort of constant. */
4440 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4441 p
= frag_more (size
);
4442 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4446 /* Otherwise, we have to create a variable sized fragment and
4447 resolve things later. */
4449 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4450 make_expr_symbol (exp
), 0, (char *) NULL
);
4454 /* Parse the .sleb128 and .uleb128 pseudos. */
4465 emit_leb128_expr (&exp
, sign
);
4467 while (*input_line_pointer
++ == ',');
4469 input_line_pointer
--;
4470 demand_empty_rest_of_line ();
4473 /* We read 0 or more ',' separated, double-quoted strings.
4474 Caller should have checked need_pass_2 is FALSE because we don't
4478 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4479 /* Checks end-of-line. */
4480 register int append_zero
; /* 0: don't append '\0', else 1. */
4482 register unsigned int c
;
4485 #ifdef md_flush_pending_output
4486 md_flush_pending_output ();
4489 /* The following awkward logic is to parse ZERO or more strings,
4490 comma separated. Recall a string expression includes spaces
4491 before the opening '\"' and spaces after the closing '\"'.
4492 We fake a leading ',' if there is (supposed to be)
4493 a 1st, expression. We keep demanding expressions for each ','. */
4494 if (is_it_end_of_statement ())
4496 c
= 0; /* Skip loop. */
4497 ++input_line_pointer
; /* Compensate for end of loop. */
4501 c
= ','; /* Do loop. */
4503 while (c
== ',' || c
== '<' || c
== '"')
4506 switch (*input_line_pointer
)
4509 ++input_line_pointer
; /*->1st char of string. */
4510 start
= input_line_pointer
;
4511 while (is_a_char (c
= next_char_of_string ()))
4513 FRAG_APPEND_1_CHAR (c
);
4517 FRAG_APPEND_1_CHAR (0);
4519 know (input_line_pointer
[-1] == '\"');
4523 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4524 will emit .string with a filename in the .debug section
4525 after a sequence of constants. See the comment in
4526 emit_expr for the sequence. emit_expr will set
4527 dwarf_file_string to non-zero if this string might be a
4528 source file name. */
4529 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4530 dwarf_file_string
= 0;
4531 else if (dwarf_file_string
)
4533 c
= input_line_pointer
[-1];
4534 input_line_pointer
[-1] = '\0';
4535 listing_source_file (start
);
4536 input_line_pointer
[-1] = c
;
4543 input_line_pointer
++;
4544 c
= get_single_number ();
4545 FRAG_APPEND_1_CHAR (c
);
4546 if (*input_line_pointer
!= '>')
4548 as_bad (_("Expected <nn>"));
4550 input_line_pointer
++;
4553 input_line_pointer
++;
4557 c
= *input_line_pointer
;
4560 demand_empty_rest_of_line ();
4563 /* FIXME-SOMEDAY: I had trouble here on characters with the
4564 high bits set. We'll probably also have trouble with
4565 multibyte chars, wide chars, etc. Also be careful about
4566 returning values bigger than 1 byte. xoxorich. */
4569 next_char_of_string ()
4571 register unsigned int c
;
4573 c
= *input_line_pointer
++ & CHAR_MASK
;
4581 as_warn (_("Unterminated string: Newline inserted."));
4582 bump_line_counters ();
4585 #ifndef NO_STRING_ESCAPES
4587 switch (c
= *input_line_pointer
++)
4615 break; /* As itself. */
4631 for (i
= 0, number
= 0;
4632 isdigit (c
) && i
< 3;
4633 c
= *input_line_pointer
++, i
++)
4635 number
= number
* 8 + c
- '0';
4640 --input_line_pointer
;
4649 c
= *input_line_pointer
++;
4650 while (isxdigit (c
))
4653 number
= number
* 16 + c
- '0';
4654 else if (isupper (c
))
4655 number
= number
* 16 + c
- 'A' + 10;
4657 number
= number
* 16 + c
- 'a' + 10;
4658 c
= *input_line_pointer
++;
4661 --input_line_pointer
;
4666 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4667 as_warn (_("Unterminated string: Newline inserted."));
4669 bump_line_counters ();
4674 #ifdef ONLY_STANDARD_ESCAPES
4675 as_bad (_("Bad escaped character in string, '?' assumed"));
4677 #endif /* ONLY_STANDARD_ESCAPES */
4682 #endif /* ! defined (NO_STRING_ESCAPES) */
4691 get_segmented_expression (expP
)
4692 register expressionS
*expP
;
4694 register segT retval
;
4696 retval
= expression (expP
);
4697 if (expP
->X_op
== O_illegal
4698 || expP
->X_op
== O_absent
4699 || expP
->X_op
== O_big
)
4701 as_bad (_("expected address expression; zero assumed"));
4702 expP
->X_op
= O_constant
;
4703 expP
->X_add_number
= 0;
4704 retval
= absolute_section
;
4710 get_known_segmented_expression (expP
)
4711 register expressionS
*expP
;
4713 register segT retval
;
4715 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4717 /* There is no easy way to extract the undefined symbol from the
4719 if (expP
->X_add_symbol
!= NULL
4720 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4721 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4722 S_GET_NAME (expP
->X_add_symbol
));
4724 as_warn (_("some symbol undefined; zero assumed"));
4725 retval
= absolute_section
;
4726 expP
->X_op
= O_constant
;
4727 expP
->X_add_number
= 0;
4729 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4734 get_absolute_expression ()
4739 if (exp
.X_op
!= O_constant
)
4741 if (exp
.X_op
!= O_absent
)
4742 as_bad (_("bad or irreducible absolute expression; zero assumed"));
4743 exp
.X_add_number
= 0;
4745 return exp
.X_add_number
;
4748 char /* Return terminator. */
4749 get_absolute_expression_and_terminator (val_pointer
)
4750 long *val_pointer
; /* Return value of expression. */
4752 /* FIXME: val_pointer should probably be offsetT *. */
4753 *val_pointer
= (long) get_absolute_expression ();
4754 return (*input_line_pointer
++);
4757 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4758 Give a warning if that happens. */
4761 demand_copy_C_string (len_pointer
)
4766 if ((s
= demand_copy_string (len_pointer
)) != 0)
4770 for (len
= *len_pointer
; len
> 0; len
--)
4777 as_bad (_("This string may not contain \'\\0\'"));
4785 /* Demand string, but return a safe (=private) copy of the string.
4786 Return NULL if we can't read a string here. */
4789 demand_copy_string (lenP
)
4792 register unsigned int c
;
4798 if (*input_line_pointer
== '\"')
4800 input_line_pointer
++; /* Skip opening quote. */
4802 while (is_a_char (c
= next_char_of_string ()))
4804 obstack_1grow (¬es
, c
);
4807 /* JF this next line is so demand_copy_C_string will return a
4808 null terminated string. */
4809 obstack_1grow (¬es
, '\0');
4810 retval
= obstack_finish (¬es
);
4814 as_warn (_("Missing string"));
4816 ignore_rest_of_line ();
4822 /* In: Input_line_pointer->next character.
4824 Do: Skip input_line_pointer over all whitespace.
4826 Out: 1 if input_line_pointer->end-of-line. */
4829 is_it_end_of_statement ()
4832 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4836 equals (sym_name
, reassign
)
4840 register symbolS
*symbolP
; /* Symbol we are working with. */
4844 input_line_pointer
++;
4845 if (*input_line_pointer
== '=')
4846 input_line_pointer
++;
4848 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4849 input_line_pointer
++;
4852 stop
= mri_comment_field (&stopc
);
4854 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4856 /* Turn '. = mumble' into a .org mumble. */
4857 register segT segment
;
4860 segment
= get_known_segmented_expression (&exp
);
4862 do_org (segment
, &exp
, 0);
4866 symbolP
= symbol_find_or_make (sym_name
);
4867 /* Permit register names to be redefined. */
4869 && S_IS_DEFINED (symbolP
)
4870 && S_GET_SEGMENT (symbolP
) != reg_section
)
4871 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
4872 pseudo_set (symbolP
);
4877 /* Check garbage after the expression. */
4878 ignore_rest_of_line ();
4879 mri_comment_end (stop
, stopc
);
4883 /* .include -- include a file at this point. */
4887 int arg ATTRIBUTE_UNUSED
;
4896 filename
= demand_copy_string (&i
);
4897 if (filename
== NULL
)
4899 /* demand_copy_string has already printed an error and
4900 called ignore_rest_of_line. */
4908 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
4909 && *input_line_pointer
!= ' '
4910 && *input_line_pointer
!= '\t')
4912 obstack_1grow (¬es
, *input_line_pointer
);
4913 ++input_line_pointer
;
4917 obstack_1grow (¬es
, '\0');
4918 filename
= obstack_finish (¬es
);
4919 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
4920 ++input_line_pointer
;
4923 demand_empty_rest_of_line ();
4924 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
4926 for (i
= 0; i
< include_dir_count
; i
++)
4928 strcpy (path
, include_dirs
[i
]);
4930 strcat (path
, filename
);
4931 if (0 != (try = fopen (path
, "r")))
4941 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
4942 register_dependency (path
);
4943 input_scrub_insert_file (path
);
4947 add_include_dir (path
)
4952 if (include_dir_count
== 0)
4954 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
4955 include_dirs
[0] = "."; /* Current dir. */
4956 include_dir_count
= 2;
4960 include_dir_count
++;
4962 (char **) realloc (include_dirs
,
4963 include_dir_count
* sizeof (*include_dirs
));
4966 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
4969 if (i
> include_dir_maxlen
)
4970 include_dir_maxlen
= i
;
4973 /* Output debugging information to denote the source file. */
4976 generate_file_debug ()
4978 if (debug_type
== DEBUG_STABS
)
4979 stabs_generate_asm_file ();
4982 /* Output line number debugging information for the current source line. */
4985 generate_lineno_debug ()
4987 #ifdef ECOFF_DEBUGGING
4988 /* ECOFF assemblers automatically generate debugging information.
4989 FIXME: This should probably be handled elsewhere. */
4990 if (debug_type
== DEBUG_UNSPECIFIED
)
4992 if (ECOFF_DEBUGGING
&& ecoff_no_current_file ())
4993 debug_type
= DEBUG_ECOFF
;
4995 debug_type
= DEBUG_NONE
;
5001 case DEBUG_UNSPECIFIED
:
5005 stabs_generate_asm_lineno ();
5008 ecoff_generate_asm_lineno ();
5012 /* This cannot safely be done in a generic manner. A single
5013 binary instruction word may span mutliple lines of assembler
5014 source and may occupy a variable number of bytes. Instead,
5015 if a port wishes to support DWARF2 line number generation by
5016 the assembler, it should add a call to dwarf2_generate_asm_lineno
5017 inside md_assemble() at whatever point is appropriate. Note,
5018 such a port should also define md_end and make sure that
5019 dwarf2_finish is called, to emit the accumulated line information. */
5024 /* Output debugging information to mark a function entry point or end point.
5025 END_P is zero for .func, and non-zero for .endfunc. */
5031 do_s_func (end_p
, NULL
);
5034 /* Subroutine of s_func so targets can choose a different default prefix.
5035 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5038 do_s_func (end_p
, default_prefix
)
5040 const char *default_prefix
;
5042 /* Record the current function so that we can issue an error message for
5043 misplaced .func,.endfunc, and also so that .endfunc needs no
5045 static char *current_name
;
5046 static char *current_label
;
5050 if (current_name
== NULL
)
5052 as_bad (_("missing .func"));
5053 ignore_rest_of_line ();
5057 if (debug_type
== DEBUG_STABS
)
5058 stabs_generate_asm_endfunc (current_name
, current_label
);
5060 current_name
= current_label
= NULL
;
5065 char delim1
, delim2
;
5067 if (current_name
!= NULL
)
5069 as_bad (_(".endfunc missing for previous .func"));
5070 ignore_rest_of_line ();
5074 name
= input_line_pointer
;
5075 delim1
= get_symbol_end ();
5076 name
= xstrdup (name
);
5077 *input_line_pointer
= delim1
;
5079 if (*input_line_pointer
!= ',')
5082 asprintf (&label
, "%s%s", default_prefix
, name
);
5085 char leading_char
= 0;
5086 #ifdef BFD_ASSEMBLER
5087 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5089 /* Missing entry point, use function's name with the leading
5092 asprintf (&label
, "%c%s", leading_char
, name
);
5099 ++input_line_pointer
;
5101 label
= input_line_pointer
;
5102 delim2
= get_symbol_end ();
5103 label
= xstrdup (label
);
5104 *input_line_pointer
= delim2
;
5107 if (debug_type
== DEBUG_STABS
)
5108 stabs_generate_asm_func (name
, label
);
5110 current_name
= name
;
5111 current_label
= label
;
5114 demand_empty_rest_of_line ();
5119 int arg ATTRIBUTE_UNUSED
;
5121 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5123 ++input_line_pointer
;
5125 ++input_line_pointer
;
5129 read_print_statistics (file
)
5132 hash_print_statistics (file
, "pseudo-op table", po_hash
);
5135 /* Inserts the given line into the input stream.
5137 This call avoids macro/conditionals nesting checking, since the contents of
5138 the line are assumed to replace the contents of a line already scanned.
5140 An appropriate use of this function would be substition of input lines when
5141 called by md_start_line_hook(). The given line is assumed to already be
5142 properly scrubbed. */
5145 input_scrub_insert_line (line
)
5150 sb_add_string (&newline
, line
);
5151 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
5153 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
5156 /* Insert a file into the input stream; the path must resolve to an actual
5157 file; no include path searching or dependency registering is performed. */
5160 input_scrub_insert_file (path
)
5163 input_scrub_include_file (path
, input_line_pointer
);
5164 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);