1 /* read.c - read a source file -
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 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 char *input_line_pointer
; /*->next char of source file to parse. */
72 #if BITS_PER_CHAR != 8
73 /* The following table is indexed by[(char)] and will break if
74 a char does not have exactly 256 states (hopefully 0:255!)! */
79 /* The m88k unfortunately uses @ as a label beginner. */
84 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
89 /* The Delta 68k assembler permits % inside label names. */
94 /* The PowerPC Windows NT assemblers permits ? inside label names. */
99 /* The IA-64 assembler uses # as a suffix designating a symbol. We include
100 it in the symbol and strip it out in tc_canonicalize_symbol_name. */
105 /* The a29k assembler does not permits labels to start with $. */
110 /* The Delta 68k assembler permits ~ at start of label names. */
114 /* Used by is_... macros. our ctype[]. */
115 char lex_type
[256] = {
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
118 0, 0, 0, LEX_HASH
, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
119 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
120 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
121 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
122 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
123 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
124 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
125 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
126 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
127 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
128 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
129 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
130 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
131 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
135 Out: 1 if this character ends a line. */
136 char is_end_of_line
[256] = {
138 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, /* @abcdefghijklmno */
140 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* @abcdefghijklmno */
142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* _!"#$%&'()*+,-./ */
144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
145 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
146 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
149 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
150 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
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, /* */
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 /* */
159 #ifdef IGNORE_OPCODE_CASE
160 char original_case_string
[128];
163 /* Functions private to this file. */
165 static char *buffer
; /* 1st char of each buffer of lines is here. */
166 static char *buffer_limit
; /*->1 + last char in buffer. */
168 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
169 in the tc-<CPU>.h file. See the "Porting GAS" section of the
171 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
173 static char *old_buffer
; /* JF a hack. */
174 static char *old_input
;
175 static char *old_limit
;
177 /* Variables for handling include file directory table. */
179 /* Table of pointers to directories to search for .include's. */
182 /* How many are in the table. */
183 int include_dir_count
;
185 /* Length of longest in table. */
186 int include_dir_maxlen
= 1;
188 #ifndef WORKING_DOT_WORD
189 struct broken_word
*broken_words
;
190 int new_broken_words
;
193 /* The current offset into the absolute section. We don't try to
194 build frags in the absolute section, since no data can be stored
195 there. We just keep track of the current offset. */
196 addressT abs_section_offset
;
198 /* If this line had an MRI style label, it is stored in this variable.
199 This is used by some of the MRI pseudo-ops. */
202 /* This global variable is used to support MRI common sections. We
203 translate such sections into a common symbol. This variable is
204 non-NULL when we are in an MRI common section. */
205 symbolS
*mri_common_symbol
;
207 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
208 need to align to an even byte boundary unless the next pseudo-op is
209 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
211 static int mri_pending_align
;
215 /* This variable is set to be non-zero if the next string we see might
216 be the name of the source file in DWARF debugging information. See
217 the comment in emit_expr for the format we look for. */
218 static int dwarf_file_string
;
222 static void cons_worker
PARAMS ((int, int));
223 static int scrub_from_string
PARAMS ((char *, int));
224 static void do_align
PARAMS ((int, char *, int, int));
225 static void s_align
PARAMS ((int, int));
226 static void s_lcomm_internal
PARAMS ((int, int));
227 static int hex_float
PARAMS ((int, char *));
228 static inline int sizeof_sleb128
PARAMS ((offsetT
));
229 static inline int sizeof_uleb128
PARAMS ((valueT
));
230 static inline int output_sleb128
PARAMS ((char *, offsetT
));
231 static inline int output_uleb128
PARAMS ((char *, valueT
));
232 static inline int output_big_sleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
233 static inline int output_big_uleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
234 static int output_big_leb128
PARAMS ((char *, LITTLENUM_TYPE
*, int, int));
235 static void do_org
PARAMS ((segT
, expressionS
*, int));
236 char *demand_copy_string
PARAMS ((int *lenP
));
237 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
238 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
239 static void pobegin
PARAMS ((void));
240 static int get_line_sb
PARAMS ((sb
*));
241 static void generate_file_debug
PARAMS ((void));
249 obj_read_begin_hook ();
251 /* Something close -- but not too close -- to a multiple of 1024.
252 The debugging malloc I'm using has 24 bytes of overhead. */
253 obstack_begin (¬es
, chunksize
);
254 obstack_begin (&cond_obstack
, chunksize
);
256 /* Use machine dependent syntax. */
257 for (p
= line_separator_chars
; *p
; p
++)
258 is_end_of_line
[(unsigned char) *p
] = 1;
259 /* Use more. FIXME-SOMEDAY. */
265 /* Set up pseudo-op tables. */
267 static struct hash_control
*po_hash
;
269 static const pseudo_typeS potable
[] = {
270 {"abort", s_abort
, 0},
271 {"align", s_align_ptwo
, 0},
272 {"ascii", stringer
, 0},
273 {"asciz", stringer
, 1},
274 {"balign", s_align_bytes
, 0},
275 {"balignw", s_align_bytes
, -2},
276 {"balignl", s_align_bytes
, -4},
280 {"common", s_mri_common
, 0},
281 {"common.s", s_mri_common
, 1},
285 {"dc.d", float_cons
, 'd'},
287 {"dc.s", float_cons
, 'f'},
289 {"dc.x", float_cons
, 'x'},
291 {"dcb.b", s_space
, 1},
292 {"dcb.d", s_float_space
, 'd'},
293 {"dcb.l", s_space
, 4},
294 {"dcb.s", s_float_space
, 'f'},
295 {"dcb.w", s_space
, 2},
296 {"dcb.x", s_float_space
, 'x'},
298 {"ds.b", s_space
, 1},
299 {"ds.d", s_space
, 8},
300 {"ds.l", s_space
, 4},
301 {"ds.p", s_space
, 12},
302 {"ds.s", s_space
, 4},
303 {"ds.w", s_space
, 2},
304 {"ds.x", s_space
, 12},
305 {"debug", s_ignore
, 0},
310 {"double", float_cons
, 'd'},
312 {"eject", listing_eject
, 0}, /* Formfeed listing. */
314 {"elsec", s_else
, 0},
315 {"elseif", s_elseif
, (int) O_ne
},
317 {"endc", s_endif
, 0},
318 {"endfunc", s_func
, 1},
319 {"endif", s_endif
, 0},
324 {"exitm", s_mexit
, 0},
326 {"extern", s_ignore
, 0}, /* We treat all undef as ext. */
327 {"appfile", s_app_file
, 1},
328 {"appline", s_app_line
, 0},
330 {"file", s_app_file
, 0},
332 {"float", float_cons
, 'f'},
333 {"format", s_ignore
, 0},
335 {"global", s_globl
, 0},
336 {"globl", s_globl
, 0},
338 {"if", s_if
, (int) O_ne
},
340 {"ifdef", s_ifdef
, 0},
341 {"ifeq", s_if
, (int) O_eq
},
342 {"ifeqs", s_ifeqs
, 0},
343 {"ifge", s_if
, (int) O_ge
},
344 {"ifgt", s_if
, (int) O_gt
},
345 {"ifle", s_if
, (int) O_le
},
346 {"iflt", s_if
, (int) O_lt
},
348 {"ifndef", s_ifdef
, 1},
349 {"ifne", s_if
, (int) O_ne
},
350 {"ifnes", s_ifeqs
, 1},
351 {"ifnotdef", s_ifdef
, 1},
352 {"include", s_include
, 0},
358 {"lcomm", s_lcomm
, 0},
359 {"lflags", listing_flags
, 0}, /* Listing flags. */
360 {"linkonce", s_linkonce
, 0},
361 {"list", listing_list
, 1}, /* Turn listing on. */
362 {"llen", listing_psize
, 1},
365 {"macro", s_macro
, 0},
366 {"mexit", s_mexit
, 0},
368 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
369 {"name", s_ignore
, 0},
370 {"noformat", s_ignore
, 0},
371 {"nolist", listing_list
, 0}, /* Turn listing off. */
372 {"nopage", listing_nopage
, 0},
374 {"offset", s_struct
, 0},
376 {"p2align", s_align_ptwo
, 0},
377 {"p2alignw", s_align_ptwo
, -2},
378 {"p2alignl", s_align_ptwo
, -4},
379 {"page", listing_eject
, 0},
380 {"plen", listing_psize
, 0},
381 {"print", s_print
, 0},
382 {"psize", listing_psize
, 0}, /* Set paper size. */
383 {"purgem", s_purgem
, 0},
388 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
393 {"single", float_cons
, 'f'},
395 {"space", s_space
, 0},
396 {"skip", s_space
, 0},
397 {"sleb128", s_leb128
, 1},
398 {"spc", s_ignore
, 0},
399 {"stabd", s_stab
, 'd'},
400 {"stabn", s_stab
, 'n'},
401 {"stabs", s_stab
, 's'},
402 {"string", stringer
, 1},
403 {"struct", s_struct
, 0},
407 /* This is for gcc to use. It's only just been added (2/94), so gcc
408 won't be able to use it for a while -- probably a year or more.
409 But once this has been released, check with gcc maintainers
410 before deleting it or even changing the spelling. */
411 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
412 /* If we're folding case -- done for some targets, not necessarily
413 all -- the above string in an input file will be converted to
414 this one. Match it either way... */
415 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
417 {"title", listing_title
, 0}, /* Listing title. */
418 {"ttl", listing_title
, 0},
420 {"uleb128", s_leb128
, 0},
424 {"xdef", s_globl
, 0},
425 {"xref", s_ignore
, 0},
426 {"xstabs", s_xstab
, 's'},
428 {"zero", s_space
, 0},
429 {NULL
, NULL
, 0} /* End sentinel. */
432 static int pop_override_ok
= 0;
433 static const char *pop_table_name
;
437 const pseudo_typeS
*table
;
440 const pseudo_typeS
*pop
;
441 for (pop
= table
; pop
->poc_name
; pop
++)
443 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
444 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
445 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
450 #ifndef md_pop_insert
451 #define md_pop_insert() pop_insert(md_pseudo_table)
454 #ifndef obj_pop_insert
455 #define obj_pop_insert() pop_insert(obj_pseudo_table)
461 po_hash
= hash_new ();
463 /* Do the target-specific pseudo ops. */
464 pop_table_name
= "md";
467 /* Now object specific. Skip any that were in the target table. */
468 pop_table_name
= "obj";
472 /* Now portable ones. Skip any that we've seen already. */
473 pop_table_name
= "standard";
474 pop_insert (potable
);
477 #define HANDLE_CONDITIONAL_ASSEMBLY() \
478 if (ignore_input ()) \
480 while (!is_end_of_line[(unsigned char) *input_line_pointer++]) \
481 if (input_line_pointer == buffer_limit) \
486 /* This function is used when scrubbing the characters between #APP
489 static char *scrub_string
;
490 static char *scrub_string_end
;
493 scrub_from_string (buf
, buflen
)
499 copy
= scrub_string_end
- scrub_string
;
502 memcpy (buf
, scrub_string
, copy
);
503 scrub_string
+= copy
;
507 /* We read the file, putting things into a web that represents what we
508 have been reading. */
510 read_a_source_file (name
)
514 register char *s
; /* String of symbol, '\0' appended. */
522 buffer
= input_scrub_new_file (name
);
525 listing_newline (NULL
);
526 register_dependency (name
);
528 /* Generate debugging information before we've read anything in to denote
529 this file as the "main" source file and not a subordinate one
530 (e.g. N_SO vs N_SOL in stabs). */
531 generate_file_debug ();
533 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
534 { /* We have another line to parse. */
535 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
536 contin
: /* JF this goto is my fault I admit it.
537 Someone brave please re-write the whole
538 input section here? Pleeze??? */
539 while (input_line_pointer
< buffer_limit
)
541 /* We have more of this buffer to parse. */
543 /* We now have input_line_pointer->1st char of next line.
544 If input_line_pointer [-1] == '\n' then we just
545 scanned another line: so bump line counters. */
546 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
548 #ifdef md_start_line_hook
549 md_start_line_hook ();
551 if (input_line_pointer
[-1] == '\n')
552 bump_line_counters ();
556 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
558 /* Text at the start of a line must be a label, we
559 run down and stick a colon in. */
560 if (is_name_beginner (*input_line_pointer
))
562 char *line_start
= input_line_pointer
;
567 HANDLE_CONDITIONAL_ASSEMBLY ();
569 c
= get_symbol_end ();
571 /* In MRI mode, the EQU and MACRO pseudoops must
572 be handled specially. */
576 char *rest
= input_line_pointer
+ 1;
580 if (*rest
== ' ' || *rest
== '\t')
582 if ((strncasecmp (rest
, "EQU", 3) == 0
583 || strncasecmp (rest
, "SET", 3) == 0)
584 && (rest
[3] == ' ' || rest
[3] == '\t'))
586 input_line_pointer
= rest
+ 3;
588 strncasecmp (rest
, "SET", 3) == 0);
591 if (strncasecmp (rest
, "MACRO", 5) == 0
594 || is_end_of_line
[(unsigned char) rest
[5]]))
598 /* In MRI mode, we need to handle the MACRO
599 pseudo-op specially: we don't want to put the
600 symbol in the symbol table. */
602 #ifdef TC_START_LABEL_WITHOUT_COLON
603 && TC_START_LABEL_WITHOUT_COLON(c
,
607 line_label
= colon (line_start
);
609 line_label
= symbol_create (line_start
,
614 *input_line_pointer
= c
;
616 input_line_pointer
++;
621 /* We are at the begining of a line, or similar place.
622 We expect a well-formed assembler statement.
623 A "symbol-name:" is a statement.
625 Depending on what compiler is used, the order of these tests
626 may vary to catch most common case 1st.
627 Each test is independent of all other tests at the (top) level.
628 PLEASE make a compiler that doesn't use this assembler.
629 It is crufty to waste a compiler's time encoding things for this
630 assembler, which then wastes more time decoding it.
631 (And communicating via (linear) files is silly!
632 If you must pass stuff, please pass a tree!) */
633 if ((c
= *input_line_pointer
++) == '\t'
637 c
= *input_line_pointer
++;
639 know (c
!= ' '); /* No further leading whitespace. */
642 /* If listing is on, and we are expanding a macro, then give
643 the listing code the contents of the expanded line. */
646 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
651 /* Find the end of the current expanded macro line. */
652 for (s
= input_line_pointer
- 1; *s
; ++s
)
653 if (is_end_of_line
[(unsigned char) *s
])
656 /* Copy it for safe keeping. Also give an indication of
657 how much macro nesting is involved at this point. */
658 len
= s
- (input_line_pointer
- 1);
659 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
660 memset (copy
, '>', macro_nest
);
661 copy
[macro_nest
] = ' ';
662 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
- 1, len
);
663 copy
[macro_nest
+ 1 + len
] = '\0';
665 /* Install the line with the listing facility. */
666 listing_newline (copy
);
669 listing_newline (NULL
);
672 /* C is the 1st significant character.
673 Input_line_pointer points after that character. */
674 if (is_name_beginner (c
))
676 /* Want user-defined label or pseudo/opcode. */
677 HANDLE_CONDITIONAL_ASSEMBLY ();
679 s
= --input_line_pointer
;
680 c
= get_symbol_end (); /* name's delimiter. */
682 /* C is character after symbol.
683 That character's place in the input line is now '\0'.
684 S points to the beginning of the symbol.
685 [In case of pseudo-op, s->'.'.]
686 Input_line_pointer->'\0' where c was. */
687 if (TC_START_LABEL (c
, input_line_pointer
))
691 char *rest
= input_line_pointer
+ 1;
693 /* In MRI mode, \tsym: set 0 is permitted. */
697 if (*rest
== ' ' || *rest
== '\t')
700 if ((strncasecmp (rest
, "EQU", 3) == 0
701 || strncasecmp (rest
, "SET", 3) == 0)
702 && (rest
[3] == ' ' || rest
[3] == '\t'))
704 input_line_pointer
= rest
+ 3;
710 line_label
= colon (s
); /* User-defined label. */
711 /* Put ':' back for error messages' sake. */
712 *input_line_pointer
++ = ':';
713 /* Input_line_pointer->after ':'. */
717 || ((c
== ' ' || c
== '\t')
718 && input_line_pointer
[1] == '='
719 #ifdef TC_EQUAL_IN_INSN
720 && !TC_EQUAL_IN_INSN (c
, input_line_pointer
)
725 demand_empty_rest_of_line ();
729 /* Expect pseudo-op or machine instruction. */
732 #ifdef IGNORE_OPCODE_CASE
736 strncpy (original_case_string
, s2
, sizeof (original_case_string
));
737 original_case_string
[sizeof (original_case_string
) - 1] = 0;
741 if (isupper ((unsigned char) *s2
))
747 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
749 /* The MRI assembler and the m88k use pseudo-ops
751 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
752 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
757 || (!flag_m68k_mri
&& *s
== '.'))
761 WARNING: c has next char, which may be end-of-line.
762 We lookup the pseudo-op table with s+1 because we
763 already know that the pseudo-op begins with a '.'. */
766 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
768 /* In MRI mode, we may need to insert an
769 automatic alignment directive. What a hack
771 if (mri_pending_align
773 || !((pop
->poc_handler
== cons
774 && pop
->poc_val
== 1)
775 || (pop
->poc_handler
== s_space
776 && pop
->poc_val
== 1)
777 #ifdef tc_conditional_pseudoop
778 || tc_conditional_pseudoop (pop
)
780 || pop
->poc_handler
== s_if
781 || pop
->poc_handler
== s_ifdef
782 || pop
->poc_handler
== s_ifc
783 || pop
->poc_handler
== s_ifeqs
784 || pop
->poc_handler
== s_else
785 || pop
->poc_handler
== s_endif
786 || pop
->poc_handler
== s_globl
787 || pop
->poc_handler
== s_ignore
)))
789 do_align (1, (char *) NULL
, 0, 0);
790 mri_pending_align
= 0;
792 if (line_label
!= NULL
)
794 symbol_set_frag (line_label
, frag_now
);
795 S_SET_VALUE (line_label
, frag_now_fix ());
799 /* Print the error msg now, while we still can. */
802 as_bad (_("Unknown pseudo-op: `%s'"), s
);
803 *input_line_pointer
= c
;
808 /* Put it back for error messages etc. */
809 *input_line_pointer
= c
;
810 /* The following skip of whitespace is compulsory.
811 A well shaped space is sometimes all that separates
812 keyword from operands. */
813 if (c
== ' ' || c
== '\t')
814 input_line_pointer
++;
816 /* Input_line is restored.
817 Input_line_pointer->1st non-blank char
818 after pseudo-operation. */
819 (*pop
->poc_handler
) (pop
->poc_val
);
821 /* If that was .end, just get out now. */
822 if (pop
->poc_handler
== s_end
)
828 #ifdef QUOTES_IN_INSN
832 /* WARNING: c has char, which may be end-of-line. */
833 /* Also: input_line_pointer->`\0` where c was. */
834 *input_line_pointer
= c
;
835 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
837 #ifdef TC_EOL_IN_INSN
838 || TC_EOL_IN_INSN (input_line_pointer
)
842 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
844 #ifdef QUOTES_IN_INSN
847 else if (*input_line_pointer
== '"')
849 else if (*input_line_pointer
== '\\')
852 input_line_pointer
++;
855 c
= *input_line_pointer
;
856 *input_line_pointer
= '\0';
858 generate_lineno_debug ();
866 if (check_macro (s
, &out
, '\0', &err
, ¯o
))
870 *input_line_pointer
++ = c
;
871 input_scrub_include_sb (&out
,
872 input_line_pointer
, 1);
875 input_scrub_next_buffer (&input_line_pointer
);
877 md_macro_info (macro
);
883 if (mri_pending_align
)
885 do_align (1, (char *) NULL
, 0, 0);
886 mri_pending_align
= 0;
887 if (line_label
!= NULL
)
889 symbol_set_frag (line_label
, frag_now
);
890 S_SET_VALUE (line_label
, frag_now_fix ());
894 md_assemble (s
); /* Assemble 1 instruction. */
896 *input_line_pointer
++ = c
;
898 /* We resume loop AFTER the end-of-line from
905 /* Empty statement? */
906 if (is_end_of_line
[(unsigned char) c
])
909 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
910 && isdigit ((unsigned char) c
))
912 /* local label ("4:") */
913 char *backup
= input_line_pointer
;
915 HANDLE_CONDITIONAL_ASSEMBLY ();
919 /* Read the whole number. */
920 while (isdigit ((unsigned char) *input_line_pointer
))
922 temp
= (temp
* 10) + *input_line_pointer
- '0';
923 ++input_line_pointer
;
926 if (LOCAL_LABELS_DOLLAR
927 && *input_line_pointer
== '$'
928 && *(input_line_pointer
+ 1) == ':')
930 input_line_pointer
+= 2;
932 if (dollar_label_defined (temp
))
934 as_fatal (_("label \"%d$\" redefined"), temp
);
937 define_dollar_label (temp
);
938 colon (dollar_label_name (temp
, 0));
943 && *input_line_pointer
++ == ':')
945 fb_label_instance_inc (temp
);
946 colon (fb_label_name (temp
, 0));
950 input_line_pointer
= backup
;
951 } /* local label ("4:") */
953 if (c
&& strchr (line_comment_chars
, c
))
954 { /* Its a comment. Better say APP or NO_APP. */
958 unsigned int new_length
;
961 bump_line_counters ();
962 s
= input_line_pointer
;
963 if (strncmp (s
, "APP\n", 4))
964 continue; /* We ignore it */
967 ends
= strstr (s
, "#NO_APP\n");
971 unsigned int tmp_len
;
974 /* The end of the #APP wasn't in this buffer. We
975 keep reading in buffers until we find the #NO_APP
976 that goes with this #APP There is one. The specs
978 tmp_len
= buffer_limit
- s
;
979 tmp_buf
= xmalloc (tmp_len
+ 1);
980 memcpy (tmp_buf
, s
, tmp_len
);
983 new_tmp
= input_scrub_next_buffer (&buffer
);
987 buffer_limit
= new_tmp
;
988 input_line_pointer
= buffer
;
989 ends
= strstr (buffer
, "#NO_APP\n");
993 num
= buffer_limit
- buffer
;
995 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
996 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
1001 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1009 input_line_pointer
= ends
+ 8;
1013 scrub_string_end
= ends
;
1015 new_length
= ends
- s
;
1016 new_buf
= (char *) xmalloc (new_length
);
1023 space
= (new_buf
+ new_length
) - new_tmp
;
1024 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1032 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1033 new_tmp
= new_buf
+ new_length
;
1039 old_buffer
= buffer
;
1040 old_input
= input_line_pointer
;
1041 old_limit
= buffer_limit
;
1043 input_line_pointer
= new_buf
;
1044 buffer_limit
= new_tmp
;
1049 HANDLE_CONDITIONAL_ASSEMBLY ();
1051 #ifdef tc_unrecognized_line
1052 if (tc_unrecognized_line (c
))
1055 /* as_warn (_("Junk character %d."),c); Now done by ignore_rest. */
1056 input_line_pointer
--; /* Report unknown char as ignored. */
1057 ignore_rest_of_line ();
1060 #ifdef md_after_pass_hook
1061 md_after_pass_hook ();
1067 bump_line_counters ();
1070 buffer
= old_buffer
;
1071 input_line_pointer
= old_input
;
1072 buffer_limit
= old_limit
;
1084 /* Close the input file. */
1085 input_scrub_close ();
1086 #ifdef WARN_COMMENTS
1088 if (warn_comment
&& found_comment
)
1089 as_warn_where (found_comment_file
, found_comment
,
1090 "first comment found here");
1095 /* For most MRI pseudo-ops, the line actually ends at the first
1096 nonquoted space. This function looks for that point, stuffs a null
1097 in, and sets *STOPCP to the character that used to be there, and
1098 returns the location.
1100 Until I hear otherwise, I am going to assume that this is only true
1101 for the m68k MRI assembler. */
1104 mri_comment_field (stopcp
)
1111 know (flag_m68k_mri
);
1113 for (s
= input_line_pointer
;
1114 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1122 for (s
= input_line_pointer
;
1123 !is_end_of_line
[(unsigned char) *s
];
1133 /* Skip to the end of an MRI comment field. */
1136 mri_comment_end (stop
, stopc
)
1142 input_line_pointer
= stop
;
1144 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1145 ++input_line_pointer
;
1150 int ignore ATTRIBUTE_UNUSED
;
1152 as_fatal (_(".abort detected. Abandoning ship."));
1155 /* Guts of .align directive. N is the power of two to which to align.
1156 FILL may be NULL, or it may point to the bytes of the fill pattern.
1157 LEN is the length of whatever FILL points to, if anything. MAX is
1158 the maximum number of characters to skip when doing the alignment,
1159 or 0 if there is no maximum. */
1162 do_align (n
, fill
, len
, max
)
1169 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1172 /* Only make a frag if we HAVE to... */
1173 if (n
!= 0 && !need_pass_2
)
1177 if (subseg_text_p (now_seg
))
1178 frag_align_code (n
, max
);
1180 frag_align (n
, 0, max
);
1183 frag_align (n
, *fill
, max
);
1185 frag_align_pattern (n
, fill
, len
, max
);
1189 just_record_alignment
:
1192 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1195 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1196 (in bytes). A negative ARG is the negative of the length of the
1197 fill pattern. BYTES_P is non-zero if the alignment value should be
1198 interpreted as the byte boundary, rather than the power of 2. */
1201 s_align (arg
, bytes_p
)
1205 register unsigned int align
;
1213 stop
= mri_comment_field (&stopc
);
1215 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1220 align
= arg
; /* Default value from pseudo-op table. */
1224 align
= get_absolute_expression ();
1230 /* Convert to a power of 2. */
1235 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1238 as_bad (_("Alignment not a power of 2"));
1247 as_bad (_("Alignment too large: %u assumed"), align
);
1250 if (*input_line_pointer
!= ',')
1257 ++input_line_pointer
;
1258 if (*input_line_pointer
== ',')
1262 fill
= get_absolute_expression ();
1267 if (*input_line_pointer
!= ',')
1271 ++input_line_pointer
;
1272 max
= get_absolute_expression ();
1279 as_warn (_("expected fill pattern missing"));
1280 do_align (align
, (char *) NULL
, 0, max
);
1295 do_align (align
, &fill_char
, fill_len
, max
);
1301 if ((size_t) fill_len
> sizeof ab
)
1303 md_number_to_chars (ab
, fill
, fill_len
);
1304 do_align (align
, ab
, fill_len
, max
);
1308 demand_empty_rest_of_line ();
1311 mri_comment_end (stop
, stopc
);
1314 /* Handle the .align pseudo-op on machines where ".align 4" means
1315 align to a 4 byte boundary. */
1324 /* Handle the .align pseudo-op on machines where ".align 4" means align
1325 to a 2**4 boundary. */
1336 int ignore ATTRIBUTE_UNUSED
;
1338 register char *name
;
1342 register symbolS
*symbolP
;
1347 stop
= mri_comment_field (&stopc
);
1349 name
= input_line_pointer
;
1350 c
= get_symbol_end ();
1351 /* Just after name is now '\0'. */
1352 p
= input_line_pointer
;
1356 if (*input_line_pointer
!= ',')
1358 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1359 ignore_rest_of_line ();
1361 mri_comment_end (stop
, stopc
);
1365 input_line_pointer
++; /* skip ',' */
1367 if ((temp
= get_absolute_expression ()) < 0)
1369 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
1370 ignore_rest_of_line ();
1372 mri_comment_end (stop
, stopc
);
1377 symbolP
= symbol_find_or_make (name
);
1380 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1382 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1383 S_GET_NAME (symbolP
));
1384 ignore_rest_of_line ();
1386 mri_comment_end (stop
, stopc
);
1390 if (S_GET_VALUE (symbolP
))
1392 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1393 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
1394 S_GET_NAME (symbolP
),
1395 (long) S_GET_VALUE (symbolP
),
1400 S_SET_VALUE (symbolP
, (valueT
) temp
);
1401 S_SET_EXTERNAL (symbolP
);
1405 extern int flag_one
;
1406 if (!temp
|| !flag_one
)
1407 S_GET_OTHER(symbolP
) = const_flag
;
1409 #endif /* not OBJ_VMS */
1410 know (symbolP
->sy_frag
== &zero_address_frag
);
1412 demand_empty_rest_of_line ();
1415 mri_comment_end (stop
, stopc
);
1418 /* The MRI COMMON pseudo-op. We handle this by creating a common
1419 symbol with the appropriate name. We make s_space do the right
1420 thing by increasing the size. */
1423 s_mri_common (small
)
1424 int small ATTRIBUTE_UNUSED
;
1440 stop
= mri_comment_field (&stopc
);
1444 name
= input_line_pointer
;
1445 if (!isdigit ((unsigned char) *name
))
1446 c
= get_symbol_end ();
1451 ++input_line_pointer
;
1453 while (isdigit ((unsigned char) *input_line_pointer
));
1455 c
= *input_line_pointer
;
1456 *input_line_pointer
= '\0';
1458 if (line_label
!= NULL
)
1460 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1461 + (input_line_pointer
- name
)
1463 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1468 sym
= symbol_find_or_make (name
);
1469 *input_line_pointer
= c
;
1473 if (*input_line_pointer
!= ',')
1477 ++input_line_pointer
;
1478 align
= get_absolute_expression ();
1481 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1483 as_bad (_("attempt to re-define symbol `%s'"), S_GET_NAME (sym
));
1484 ignore_rest_of_line ();
1485 mri_comment_end (stop
, stopc
);
1489 S_SET_EXTERNAL (sym
);
1490 mri_common_symbol
= sym
;
1494 S_SET_ALIGN (sym
, align
);
1497 if (line_label
!= NULL
)
1500 exp
.X_op
= O_symbol
;
1501 exp
.X_add_symbol
= sym
;
1502 exp
.X_add_number
= 0;
1503 symbol_set_value_expression (line_label
, &exp
);
1504 symbol_set_frag (line_label
, &zero_address_frag
);
1505 S_SET_SEGMENT (line_label
, expr_section
);
1508 /* FIXME: We just ignore the small argument, which distinguishes
1509 COMMON and COMMON.S. I don't know what we can do about it. */
1511 /* Ignore the type and hptype. */
1512 if (*input_line_pointer
== ',')
1513 input_line_pointer
+= 2;
1514 if (*input_line_pointer
== ',')
1515 input_line_pointer
+= 2;
1517 demand_empty_rest_of_line ();
1519 mri_comment_end (stop
, stopc
);
1524 int ignore ATTRIBUTE_UNUSED
;
1529 temp
= get_absolute_expression ();
1530 if (flag_readonly_data_in_text
)
1532 section
= text_section
;
1536 section
= data_section
;
1538 subseg_set (section
, (subsegT
) temp
);
1543 demand_empty_rest_of_line ();
1546 /* Handle the .appfile pseudo-op. This is automatically generated by
1547 do_scrub_chars when a preprocessor # line comment is seen with a
1548 file name. This default definition may be overridden by the object
1549 or CPU specific pseudo-ops. This function is also the default
1550 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1554 s_app_file (appfile
)
1560 /* Some assemblers tolerate immediately following '"'. */
1561 if ((s
= demand_copy_string (&length
)) != 0)
1563 /* If this is a fake .appfile, a fake newline was inserted into
1564 the buffer. Passing -2 to new_logical_line tells it to
1567 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1569 /* In MRI mode, the preprocessor may have inserted an extraneous
1572 && *input_line_pointer
== '\''
1573 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1574 ++input_line_pointer
;
1576 demand_empty_rest_of_line ();
1581 listing_source_file (s
);
1583 register_dependency (s
);
1591 /* Handle the .appline pseudo-op. This is automatically generated by
1592 do_scrub_chars when a preprocessor # line comment is seen. This
1593 default definition may be overridden by the object or CPU specific
1598 int ignore ATTRIBUTE_UNUSED
;
1602 /* The given number is that of the next line. */
1603 l
= get_absolute_expression () - 1;
1605 /* Some of the back ends can't deal with non-positive line numbers.
1606 Besides, it's silly. */
1607 as_warn (_("Line numbers must be positive; line number %d rejected."),
1611 new_logical_line ((char *) NULL
, l
);
1614 listing_source_line (l
);
1617 demand_empty_rest_of_line ();
1620 /* Handle the .end pseudo-op. Actually, the real work is done in
1621 read_a_source_file. */
1625 int ignore ATTRIBUTE_UNUSED
;
1629 /* The MRI assembler permits the start symbol to follow .end,
1630 but we don't support that. */
1632 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1633 && *input_line_pointer
!= '*'
1634 && *input_line_pointer
!= '!')
1635 as_warn (_("start address not supported"));
1639 /* Handle the .err pseudo-op. */
1643 int ignore ATTRIBUTE_UNUSED
;
1645 as_bad (_(".err encountered"));
1646 demand_empty_rest_of_line ();
1649 /* Handle the MRI fail pseudo-op. */
1653 int ignore ATTRIBUTE_UNUSED
;
1660 stop
= mri_comment_field (&stopc
);
1662 temp
= get_absolute_expression ();
1664 as_warn (_(".fail %ld encountered"), (long) temp
);
1666 as_bad (_(".fail %ld encountered"), (long) temp
);
1668 demand_empty_rest_of_line ();
1671 mri_comment_end (stop
, stopc
);
1676 int ignore ATTRIBUTE_UNUSED
;
1678 expressionS rep_exp
;
1680 register long fill
= 0;
1683 #ifdef md_flush_pending_output
1684 md_flush_pending_output ();
1687 get_known_segmented_expression (&rep_exp
);
1688 if (*input_line_pointer
== ',')
1690 input_line_pointer
++;
1691 size
= get_absolute_expression ();
1692 if (*input_line_pointer
== ',')
1694 input_line_pointer
++;
1695 fill
= get_absolute_expression ();
1699 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1700 #define BSD_FILL_SIZE_CROCK_8 (8)
1701 if (size
> BSD_FILL_SIZE_CROCK_8
)
1703 as_warn (_(".fill size clamped to %d."), BSD_FILL_SIZE_CROCK_8
);
1704 size
= BSD_FILL_SIZE_CROCK_8
;
1708 as_warn (_("Size negative: .fill ignored."));
1711 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1713 if (rep_exp
.X_add_number
< 0)
1714 as_warn (_("Repeat < 0, .fill ignored"));
1718 if (size
&& !need_pass_2
)
1720 if (rep_exp
.X_op
== O_constant
)
1722 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1723 (relax_substateT
) 0, (symbolS
*) 0,
1724 (offsetT
) rep_exp
.X_add_number
,
1729 /* We don't have a constant repeat count, so we can't use
1730 rs_fill. We can get the same results out of rs_space,
1731 but its argument is in bytes, so we must multiply the
1732 repeat count by size. */
1735 rep_sym
= make_expr_symbol (&rep_exp
);
1738 expressionS size_exp
;
1739 size_exp
.X_op
= O_constant
;
1740 size_exp
.X_add_number
= size
;
1742 rep_exp
.X_op
= O_multiply
;
1743 rep_exp
.X_add_symbol
= rep_sym
;
1744 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1745 rep_exp
.X_add_number
= 0;
1746 rep_sym
= make_expr_symbol (&rep_exp
);
1749 p
= frag_var (rs_space
, (int) size
, (int) size
,
1750 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1753 memset (p
, 0, (unsigned int) size
);
1755 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1756 flavoured AS. The following bizzare behaviour is to be
1757 compatible with above. I guess they tried to take up to 8
1758 bytes from a 4-byte expression and they forgot to sign
1759 extend. Un*x Sux. */
1760 #define BSD_FILL_SIZE_CROCK_4 (4)
1761 md_number_to_chars (p
, (valueT
) fill
,
1762 (size
> BSD_FILL_SIZE_CROCK_4
1763 ? BSD_FILL_SIZE_CROCK_4
1765 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1766 but emits no error message because it seems a legal thing to do.
1767 It is a degenerate case of .fill but could be emitted by a
1770 demand_empty_rest_of_line ();
1775 int ignore ATTRIBUTE_UNUSED
;
1784 stop
= mri_comment_field (&stopc
);
1788 name
= input_line_pointer
;
1789 c
= get_symbol_end ();
1790 symbolP
= symbol_find_or_make (name
);
1791 S_SET_EXTERNAL (symbolP
);
1793 *input_line_pointer
= c
;
1795 c
= *input_line_pointer
;
1798 input_line_pointer
++;
1800 if (*input_line_pointer
== '\n')
1806 demand_empty_rest_of_line ();
1809 mri_comment_end (stop
, stopc
);
1812 /* Handle the MRI IRP and IRPC pseudo-ops. */
1824 as_where (&file
, &line
);
1827 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1828 sb_add_char (&s
, *input_line_pointer
++);
1832 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1834 as_bad_where (file
, line
, "%s", err
);
1838 input_scrub_include_sb (&out
, input_line_pointer
, 1);
1840 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1843 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1844 the section to only be linked once. However, this is not supported
1845 by most object file formats. This takes an optional argument,
1846 which is what to do about duplicates. */
1850 int ignore ATTRIBUTE_UNUSED
;
1852 enum linkonce_type type
;
1856 type
= LINKONCE_DISCARD
;
1858 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1863 s
= input_line_pointer
;
1864 c
= get_symbol_end ();
1865 if (strcasecmp (s
, "discard") == 0)
1866 type
= LINKONCE_DISCARD
;
1867 else if (strcasecmp (s
, "one_only") == 0)
1868 type
= LINKONCE_ONE_ONLY
;
1869 else if (strcasecmp (s
, "same_size") == 0)
1870 type
= LINKONCE_SAME_SIZE
;
1871 else if (strcasecmp (s
, "same_contents") == 0)
1872 type
= LINKONCE_SAME_CONTENTS
;
1874 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1876 *input_line_pointer
= c
;
1879 #ifdef obj_handle_link_once
1880 obj_handle_link_once (type
);
1881 #else /* ! defined (obj_handle_link_once) */
1882 #ifdef BFD_ASSEMBLER
1886 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1887 as_warn (_(".linkonce is not supported for this object file format"));
1889 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1890 flags
|= SEC_LINK_ONCE
;
1895 case LINKONCE_DISCARD
:
1896 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1898 case LINKONCE_ONE_ONLY
:
1899 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1901 case LINKONCE_SAME_SIZE
:
1902 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1904 case LINKONCE_SAME_CONTENTS
:
1905 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1908 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1909 as_bad (_("bfd_set_section_flags: %s"),
1910 bfd_errmsg (bfd_get_error ()));
1912 #else /* ! defined (BFD_ASSEMBLER) */
1913 as_warn (_(".linkonce is not supported for this object file format"));
1914 #endif /* ! defined (BFD_ASSEMBLER) */
1915 #endif /* ! defined (obj_handle_link_once) */
1917 demand_empty_rest_of_line ();
1921 s_lcomm_internal (needs_align
, bytes_p
)
1922 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1923 (alignment); 0 if it was an ".lcomm" (2 args only). */
1925 /* 1 if the alignment value should be interpreted as the byte boundary,
1926 rather than the power of 2. */
1929 register char *name
;
1933 register symbolS
*symbolP
;
1934 segT current_seg
= now_seg
;
1935 subsegT current_subseg
= now_subseg
;
1936 const int max_alignment
= 15;
1938 segT bss_seg
= bss_section
;
1940 name
= input_line_pointer
;
1941 c
= get_symbol_end ();
1942 p
= input_line_pointer
;
1946 /* Accept an optional comma after the name. The comma used to be
1947 required, but Irix 5 cc does not generate it. */
1948 if (*input_line_pointer
== ',')
1950 ++input_line_pointer
;
1954 if (*input_line_pointer
== '\n')
1956 as_bad (_("Missing size expression"));
1960 if ((temp
= get_absolute_expression ()) < 0)
1962 as_warn (_("BSS length (%d.) <0! Ignored."), temp
);
1963 ignore_rest_of_line ();
1967 #if defined (TC_MIPS) || defined (TC_ALPHA)
1968 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1969 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1971 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1972 if (temp
<= bfd_get_gp_size (stdoutput
))
1974 bss_seg
= subseg_new (".sbss", 1);
1975 seg_info (bss_seg
)->bss
= 1;
1976 #ifdef BFD_ASSEMBLER
1977 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1978 as_warn (_("error setting flags for \".sbss\": %s"),
1979 bfd_errmsg (bfd_get_error ()));
1987 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
1989 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
1991 record_alignment (bss_seg
, align
);
1999 if (*input_line_pointer
!= ',')
2001 as_bad (_("Expected comma after size"));
2002 ignore_rest_of_line ();
2006 input_line_pointer
++;
2009 if (*input_line_pointer
== '\n')
2011 as_bad (_("Missing alignment"));
2015 align
= get_absolute_expression ();
2019 /* Convert to a power of 2. */
2024 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2027 as_bad (_("Alignment not a power of 2"));
2032 if (align
> max_alignment
)
2034 align
= max_alignment
;
2035 as_warn (_("Alignment too large: %d. assumed."), align
);
2040 as_warn (_("Alignment negative. 0 assumed."));
2043 record_alignment (bss_seg
, align
);
2047 /* Assume some objects may require alignment on some systems. */
2048 #if defined (TC_ALPHA) && ! defined (VMS)
2051 align
= ffs (temp
) - 1;
2052 if (temp
% (1 << align
))
2059 symbolP
= symbol_find_or_make (name
);
2063 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2064 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2065 #ifdef BFD_ASSEMBLER
2066 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2067 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2069 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2072 (S_GET_SEGMENT (symbolP
) == bss_seg
2073 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2077 subseg_set (bss_seg
, 1);
2080 frag_align (align
, 0, 0);
2082 /* Detach from old frag. */
2083 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2084 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2086 symbol_set_frag (symbolP
, frag_now
);
2087 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2088 (offsetT
) temp
, (char *) 0);
2091 S_SET_SEGMENT (symbolP
, bss_seg
);
2094 /* The symbol may already have been created with a preceding
2095 ".globl" directive -- be careful not to step on storage class
2096 in that case. Otherwise, set it to static. */
2097 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2099 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2101 #endif /* OBJ_COFF */
2104 S_SET_SIZE (symbolP
, temp
);
2108 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
2109 S_GET_NAME (symbolP
));
2111 subseg_set (current_seg
, current_subseg
);
2113 demand_empty_rest_of_line ();
2117 s_lcomm (needs_align
)
2120 s_lcomm_internal (needs_align
, 0);
2124 s_lcomm_bytes (needs_align
)
2127 s_lcomm_internal (needs_align
, 1);
2132 int ignore ATTRIBUTE_UNUSED
;
2134 register char *name
;
2138 register symbolS
*symbolP
;
2140 /* We permit ANY defined expression: BSD4.2 demands constants. */
2141 name
= input_line_pointer
;
2142 c
= get_symbol_end ();
2143 p
= input_line_pointer
;
2147 if (*input_line_pointer
!= ',')
2150 as_bad (_("Expected comma after name \"%s\""), name
);
2152 ignore_rest_of_line ();
2156 input_line_pointer
++;
2159 if (exp
.X_op
!= O_constant
2160 && exp
.X_op
!= O_register
)
2162 as_bad (_("bad expression"));
2163 ignore_rest_of_line ();
2168 symbolP
= symbol_find_or_make (name
);
2170 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2171 symbolP->sy_desc == 0) out of this test because coff doesn't have
2172 those fields, and I can't see when they'd ever be tripped. I
2173 don't think I understand why they were here so I may have
2174 introduced a bug. As recently as 1.37 didn't have this test
2175 anyway. xoxorich. */
2177 if (S_GET_SEGMENT (symbolP
) == undefined_section
2178 && S_GET_VALUE (symbolP
) == 0)
2180 /* The name might be an undefined .global symbol; be sure to
2181 keep the "external" bit. */
2182 S_SET_SEGMENT (symbolP
,
2183 (exp
.X_op
== O_constant
2186 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2190 as_bad (_("Symbol %s already defined"), name
);
2194 demand_empty_rest_of_line ();
2197 /* Read a line into an sb. */
2203 char quote1
, quote2
, inquote
;
2205 if (input_line_pointer
[-1] == '\n')
2206 bump_line_counters ();
2208 if (input_line_pointer
>= buffer_limit
)
2210 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2211 if (buffer_limit
== 0)
2215 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2216 code needs to be changed. */
2225 #ifdef LEX_IS_STRINGQUOTE
2231 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2232 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2234 if (inquote
== *input_line_pointer
)
2236 else if (inquote
== '\0')
2238 if (*input_line_pointer
== quote1
)
2240 else if (*input_line_pointer
== quote2
)
2244 sb_add_char (line
, *input_line_pointer
++);
2247 while (input_line_pointer
< buffer_limit
2248 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2250 if (input_line_pointer
[-1] == '\n')
2251 bump_line_counters ();
2252 ++input_line_pointer
;
2258 /* Define a macro. This is an interface to macro.c, which is shared
2259 between gas and gasp. */
2263 int ignore ATTRIBUTE_UNUSED
;
2272 as_where (&file
, &line
);
2275 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2276 sb_add_char (&s
, *input_line_pointer
++);
2279 if (line_label
!= NULL
)
2280 sb_add_string (&label
, S_GET_NAME (line_label
));
2282 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2284 as_bad_where (file
, line
, "%s", err
);
2287 if (line_label
!= NULL
)
2289 S_SET_SEGMENT (line_label
, undefined_section
);
2290 S_SET_VALUE (line_label
, 0);
2291 symbol_set_frag (line_label
, &zero_address_frag
);
2294 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2295 && hash_find (po_hash
, name
) != NULL
)
2298 && hash_find (po_hash
, name
+ 1) != NULL
))
2299 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2306 /* Handle the .mexit pseudo-op, which immediately exits a macro
2311 int ignore ATTRIBUTE_UNUSED
;
2313 cond_exit_macro (macro_nest
);
2314 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2317 /* Switch in and out of MRI mode. */
2321 int ignore ATTRIBUTE_UNUSED
;
2325 on
= get_absolute_expression ();
2326 old_flag
= flag_mri
;
2344 /* Operator precedence changes in m68k MRI mode, so we need to
2345 update the operator rankings. */
2346 expr_set_precedence ();
2348 #ifdef MRI_MODE_CHANGE
2350 MRI_MODE_CHANGE (on
);
2353 demand_empty_rest_of_line ();
2356 /* Handle changing the location counter. */
2359 do_org (segment
, exp
, fill
)
2364 if (segment
!= now_seg
&& segment
!= absolute_section
)
2365 as_bad (_("invalid segment \"%s\"; segment \"%s\" assumed"),
2366 segment_name (segment
), segment_name (now_seg
));
2368 if (now_seg
== absolute_section
)
2371 as_warn (_("ignoring fill value in absolute section"));
2372 if (exp
->X_op
!= O_constant
)
2374 as_bad (_("only constant offsets supported in absolute section"));
2375 exp
->X_add_number
= 0;
2377 abs_section_offset
= exp
->X_add_number
;
2382 symbolS
*sym
= exp
->X_add_symbol
;
2383 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2385 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2387 /* Handle complex expressions. */
2388 sym
= make_expr_symbol (exp
);
2392 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2399 int ignore ATTRIBUTE_UNUSED
;
2401 register segT segment
;
2403 register long temp_fill
;
2405 #ifdef md_flush_pending_output
2406 md_flush_pending_output ();
2409 /* The m68k MRI assembler has a different meaning for .org. It
2410 means to create an absolute section at a given address. We can't
2411 support that--use a linker script instead. */
2414 as_bad (_("MRI style ORG pseudo-op not supported"));
2415 ignore_rest_of_line ();
2419 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2420 thing as a sub-segment-relative origin. Any absolute origin is
2421 given a warning, then assumed to be segment-relative. Any
2422 segmented origin expression ("foo+42") had better be in the right
2423 segment or the .org is ignored.
2425 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2426 we never know sub-segment sizes when we are reading code. BSD
2427 will crash trying to emit negative numbers of filler bytes in
2428 certain .orgs. We don't crash, but see as-write for that code.
2430 Don't make frag if need_pass_2==1. */
2431 segment
= get_known_segmented_expression (&exp
);
2432 if (*input_line_pointer
== ',')
2434 input_line_pointer
++;
2435 temp_fill
= get_absolute_expression ();
2441 do_org (segment
, &exp
, temp_fill
);
2443 demand_empty_rest_of_line ();
2446 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2447 called by the obj-format routine which handles section changing
2448 when in MRI mode. It will create a new section, and return it. It
2449 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2450 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2451 flags will be set in the section. */
2455 char *type ATTRIBUTE_UNUSED
;
2465 name
= input_line_pointer
;
2466 if (!isdigit ((unsigned char) *name
))
2467 c
= get_symbol_end ();
2472 ++input_line_pointer
;
2474 while (isdigit ((unsigned char) *input_line_pointer
));
2476 c
= *input_line_pointer
;
2477 *input_line_pointer
= '\0';
2480 name
= xstrdup (name
);
2482 *input_line_pointer
= c
;
2484 seg
= subseg_new (name
, 0);
2486 if (*input_line_pointer
== ',')
2490 ++input_line_pointer
;
2491 align
= get_absolute_expression ();
2492 record_alignment (seg
, align
);
2496 if (*input_line_pointer
== ',')
2498 c
= *++input_line_pointer
;
2499 c
= toupper ((unsigned char) c
);
2500 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2503 as_bad (_("unrecognized section type"));
2504 ++input_line_pointer
;
2506 #ifdef BFD_ASSEMBLER
2510 flags
= SEC_NO_FLAGS
;
2512 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2513 else if (*type
== 'D' || *type
== 'M')
2514 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2515 else if (*type
== 'R')
2516 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2517 if (flags
!= SEC_NO_FLAGS
)
2519 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2520 as_warn (_("error setting flags for \"%s\": %s"),
2521 bfd_section_name (stdoutput
, seg
),
2522 bfd_errmsg (bfd_get_error ()));
2528 /* Ignore the HP type. */
2529 if (*input_line_pointer
== ',')
2530 input_line_pointer
+= 2;
2532 demand_empty_rest_of_line ();
2534 #else /* ! TC_M68K */
2543 name
= input_line_pointer
;
2544 c
= get_symbol_end ();
2546 name
= xstrdup (name
);
2548 *input_line_pointer
= c
;
2550 seg
= subseg_new (name
, 0);
2552 if (*input_line_pointer
!= ',')
2558 ++input_line_pointer
;
2560 sectype
= input_line_pointer
;
2561 c
= get_symbol_end ();
2562 if (*sectype
== '\0')
2564 else if (strcasecmp (sectype
, "text") == 0)
2566 else if (strcasecmp (sectype
, "data") == 0)
2568 else if (strcasecmp (sectype
, "romdata") == 0)
2571 as_warn (_("unrecognized section type `%s'"), sectype
);
2572 *input_line_pointer
= c
;
2575 if (*input_line_pointer
== ',')
2579 ++input_line_pointer
;
2581 seccmd
= input_line_pointer
;
2582 c
= get_symbol_end ();
2583 if (strcasecmp (seccmd
, "absolute") == 0)
2585 as_bad (_("absolute sections are not supported"));
2586 *input_line_pointer
= c
;
2587 ignore_rest_of_line ();
2590 else if (strcasecmp (seccmd
, "align") == 0)
2594 *input_line_pointer
= c
;
2595 align
= get_absolute_expression ();
2596 record_alignment (seg
, align
);
2600 as_warn (_("unrecognized section command `%s'"), seccmd
);
2601 *input_line_pointer
= c
;
2605 demand_empty_rest_of_line ();
2607 #else /* ! TC_I960 */
2608 /* The MRI assembler seems to use different forms of .sect for
2609 different targets. */
2610 as_bad ("MRI mode not supported for this target");
2611 ignore_rest_of_line ();
2612 #endif /* ! TC_I960 */
2613 #endif /* ! TC_M68K */
2616 /* Handle the .print pseudo-op. */
2620 int ignore ATTRIBUTE_UNUSED
;
2625 s
= demand_copy_C_string (&len
);
2627 demand_empty_rest_of_line ();
2630 /* Handle the .purgem pseudo-op. */
2634 int ignore ATTRIBUTE_UNUSED
;
2636 if (is_it_end_of_statement ())
2638 demand_empty_rest_of_line ();
2648 name
= input_line_pointer
;
2649 c
= get_symbol_end ();
2650 delete_macro (name
);
2651 *input_line_pointer
= c
;
2654 while (*input_line_pointer
++ == ',');
2656 --input_line_pointer
;
2657 demand_empty_rest_of_line ();
2660 /* Handle the .rept pseudo-op. */
2664 int ignore ATTRIBUTE_UNUSED
;
2668 count
= get_absolute_expression ();
2670 do_repeat (count
, "REPT", "ENDR");
2673 /* This function provides a generic repeat block implementation. It allows
2674 different directives to be used as the start/end keys. */
2677 do_repeat (count
, start
, end
)
2686 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2688 as_bad (_("%s without %s"), start
, end
);
2694 sb_add_sb (&many
, &one
);
2698 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2700 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2703 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2704 input buffers to skip. Assumes that conditionals preceding the loop end
2705 are properly nested.
2707 This function makes it easier to implement a premature "break" out of the
2708 loop. The EXTRA arg accounts for other buffers we might have inserted,
2709 such as line substitutions. */
2715 cond_exit_macro (macro_nest
);
2716 while (extra
-- >= 0)
2717 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2720 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2721 this is .equiv, and it is an error if the symbol is already
2728 register char *name
;
2729 register char delim
;
2730 register char *end_name
;
2731 register symbolS
*symbolP
;
2733 /* Especial apologies for the random logic:
2734 this just grew, and could be parsed much more simply!
2736 name
= input_line_pointer
;
2737 delim
= get_symbol_end ();
2738 end_name
= input_line_pointer
;
2742 if (*input_line_pointer
!= ',')
2745 as_bad (_("Expected comma after name \"%s\""), name
);
2747 ignore_rest_of_line ();
2751 input_line_pointer
++;
2754 if (name
[0] == '.' && name
[1] == '\0')
2756 /* Turn '. = mumble' into a .org mumble. */
2757 register segT segment
;
2760 segment
= get_known_segmented_expression (&exp
);
2763 do_org (segment
, &exp
, 0);
2769 if ((symbolP
= symbol_find (name
)) == NULL
2770 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2773 /* When doing symbol listings, play games with dummy fragments living
2774 outside the normal fragment chain to record the file and line info
2776 if (listing
& LISTING_SYMBOLS
)
2778 extern struct list_info_struct
*listing_tail
;
2779 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2780 memset (dummy_frag
, 0, sizeof (fragS
));
2781 dummy_frag
->fr_type
= rs_fill
;
2782 dummy_frag
->line
= listing_tail
;
2783 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2784 dummy_frag
->fr_symbol
= symbolP
;
2788 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2791 /* "set" symbols are local unless otherwise specified. */
2792 SF_SET_LOCAL (symbolP
);
2793 #endif /* OBJ_COFF */
2796 symbol_table_insert (symbolP
);
2801 && S_IS_DEFINED (symbolP
)
2802 && S_GET_SEGMENT (symbolP
) != reg_section
)
2803 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
2805 pseudo_set (symbolP
);
2806 demand_empty_rest_of_line ();
2820 #ifdef md_flush_pending_output
2821 md_flush_pending_output ();
2825 stop
= mri_comment_field (&stopc
);
2827 /* In m68k MRI mode, we need to align to a word boundary, unless
2829 if (flag_m68k_mri
&& mult
> 1)
2831 if (now_seg
== absolute_section
)
2833 abs_section_offset
+= abs_section_offset
& 1;
2834 if (line_label
!= NULL
)
2835 S_SET_VALUE (line_label
, abs_section_offset
);
2837 else if (mri_common_symbol
!= NULL
)
2841 val
= S_GET_VALUE (mri_common_symbol
);
2844 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2845 if (line_label
!= NULL
)
2847 expressionS
*symexp
;
2849 symexp
= symbol_get_value_expression (line_label
);
2850 know (symexp
->X_op
== O_symbol
);
2851 know (symexp
->X_add_symbol
== mri_common_symbol
);
2852 symexp
->X_add_number
+= 1;
2858 do_align (1, (char *) NULL
, 0, 0);
2859 if (line_label
!= NULL
)
2861 symbol_set_frag (line_label
, frag_now
);
2862 S_SET_VALUE (line_label
, frag_now_fix ());
2872 if (*input_line_pointer
== ',')
2874 ++input_line_pointer
;
2879 val
.X_op
= O_constant
;
2880 val
.X_add_number
= 0;
2883 if (val
.X_op
!= O_constant
2884 || val
.X_add_number
< - 0x80
2885 || val
.X_add_number
> 0xff
2886 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2888 if (exp
.X_op
!= O_constant
)
2889 as_bad (_("Unsupported variable size or fill value"));
2896 bytes
= mult
* exp
.X_add_number
;
2897 for (i
= 0; i
< exp
.X_add_number
; i
++)
2898 emit_expr (&val
, mult
);
2903 if (exp
.X_op
== O_constant
)
2907 repeat
= exp
.X_add_number
;
2914 as_warn (_(".space repeat count is zero, ignored"));
2915 else if (repeat
< 0)
2916 as_warn (_(".space repeat count is negative, ignored"));
2920 /* If we are in the absolute section, just bump the offset. */
2921 if (now_seg
== absolute_section
)
2923 abs_section_offset
+= repeat
;
2927 /* If we are secretly in an MRI common section, then
2928 creating space just increases the size of the common
2930 if (mri_common_symbol
!= NULL
)
2932 S_SET_VALUE (mri_common_symbol
,
2933 S_GET_VALUE (mri_common_symbol
) + repeat
);
2938 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2939 (offsetT
) repeat
, (char *) 0);
2943 if (now_seg
== absolute_section
)
2945 as_bad (_("space allocation too complex in absolute section"));
2946 subseg_set (text_section
, 0);
2949 if (mri_common_symbol
!= NULL
)
2951 as_bad (_("space allocation too complex in common section"));
2952 mri_common_symbol
= NULL
;
2956 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2957 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2961 *p
= val
.X_add_number
;
2966 /* In MRI mode, after an odd number of bytes, we must align to an
2967 even word boundary, unless the next instruction is a dc.b, ds.b
2969 if (flag_mri
&& (bytes
& 1) != 0)
2970 mri_pending_align
= 1;
2972 demand_empty_rest_of_line ();
2975 mri_comment_end (stop
, stopc
);
2978 /* This is like s_space, but the value is a floating point number with
2979 the given precision. This is for the MRI dcb.s pseudo-op and
2983 s_float_space (float_type
)
2988 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2993 stop
= mri_comment_field (&stopc
);
2995 count
= get_absolute_expression ();
2998 if (*input_line_pointer
!= ',')
3000 as_bad (_("missing value"));
3001 ignore_rest_of_line ();
3003 mri_comment_end (stop
, stopc
);
3007 ++input_line_pointer
;
3011 /* Skip any 0{letter} that may be present. Don't even check if the
3012 * letter is legal. */
3013 if (input_line_pointer
[0] == '0'
3014 && isalpha ((unsigned char) input_line_pointer
[1]))
3015 input_line_pointer
+= 2;
3017 /* Accept :xxxx, where the x's are hex digits, for a floating point
3018 with the exact digits specified. */
3019 if (input_line_pointer
[0] == ':')
3021 flen
= hex_float (float_type
, temp
);
3024 ignore_rest_of_line ();
3026 mri_comment_end (stop
, stopc
);
3034 err
= md_atof (float_type
, temp
, &flen
);
3035 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3039 as_bad (_("Bad floating literal: %s"), err
);
3040 ignore_rest_of_line ();
3042 mri_comment_end (stop
, stopc
);
3047 while (--count
>= 0)
3051 p
= frag_more (flen
);
3052 memcpy (p
, temp
, (unsigned int) flen
);
3055 demand_empty_rest_of_line ();
3058 mri_comment_end (stop
, stopc
);
3061 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3065 int ignore ATTRIBUTE_UNUSED
;
3071 stop
= mri_comment_field (&stopc
);
3072 abs_section_offset
= get_absolute_expression ();
3073 subseg_set (absolute_section
, 0);
3074 demand_empty_rest_of_line ();
3076 mri_comment_end (stop
, stopc
);
3081 int ignore ATTRIBUTE_UNUSED
;
3085 temp
= get_absolute_expression ();
3086 subseg_set (text_section
, (subsegT
) temp
);
3087 demand_empty_rest_of_line ();
3089 const_flag
&= ~IN_DEFAULT_SECTION
;
3094 demand_empty_rest_of_line ()
3097 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3098 input_line_pointer
++;
3100 ignore_rest_of_line ();
3102 /* Return having already swallowed end-of-line. */
3106 ignore_rest_of_line ()
3108 /* For suspect lines: gives warning. */
3109 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3111 if (isprint ((unsigned char) *input_line_pointer
))
3112 as_bad (_("Rest of line ignored. First ignored character is `%c'."),
3113 *input_line_pointer
);
3115 as_bad (_("Rest of line ignored. First ignored character valued 0x%x."),
3116 *input_line_pointer
);
3118 while (input_line_pointer
< buffer_limit
3119 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3120 input_line_pointer
++;
3123 input_line_pointer
++;
3125 /* Return pointing just after end-of-line. */
3126 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3130 discard_rest_of_line ()
3132 while (input_line_pointer
< buffer_limit
3133 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3134 input_line_pointer
++;
3136 input_line_pointer
++;
3138 /* Return pointing just after end-of-line. */
3139 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3142 /* In: Pointer to a symbol.
3143 Input_line_pointer->expression.
3145 Out: Input_line_pointer->just after any whitespace after expression.
3146 Tried to set symbol to value of expression.
3147 Will change symbols type, value, and frag; */
3150 pseudo_set (symbolP
)
3155 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3157 #endif /* OBJ_AOUT or OBJ_BOUT */
3159 know (symbolP
); /* NULL pointer is logic error. */
3160 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3161 ext
= S_IS_EXTERNAL (symbolP
);
3162 #endif /* OBJ_AOUT or OBJ_BOUT */
3164 seg
= expression (&exp
);
3166 if (exp
.X_op
== O_illegal
)
3167 as_bad (_("illegal expression; zero assumed"));
3168 else if (exp
.X_op
== O_absent
)
3169 as_bad (_("missing expression; zero assumed"));
3170 else if (exp
.X_op
== O_big
)
3172 if (exp
.X_add_number
> 0)
3173 as_bad (_("bignum invalid; zero assumed"));
3175 as_bad (_("floating point number invalid; zero assumed"));
3177 else if (exp
.X_op
== O_subtract
3178 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3179 == S_GET_SEGMENT (exp
.X_op_symbol
))
3180 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3181 && (symbol_get_frag (exp
.X_add_symbol
)
3182 == symbol_get_frag (exp
.X_op_symbol
)))
3184 exp
.X_op
= O_constant
;
3185 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3186 - S_GET_VALUE (exp
.X_op_symbol
));
3194 exp
.X_add_number
= 0;
3197 S_SET_SEGMENT (symbolP
, absolute_section
);
3198 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3200 S_SET_EXTERNAL (symbolP
);
3202 S_CLEAR_EXTERNAL (symbolP
);
3203 #endif /* OBJ_AOUT or OBJ_BOUT */
3204 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3205 if (exp
.X_op
!= O_constant
)
3206 symbol_set_frag (symbolP
, &zero_address_frag
);
3210 S_SET_SEGMENT (symbolP
, reg_section
);
3211 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3212 symbol_set_frag (symbolP
, &zero_address_frag
);
3216 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3217 || exp
.X_add_number
!= 0)
3218 symbol_set_value_expression (symbolP
, &exp
);
3219 else if (symbol_section_p (symbolP
))
3220 as_bad ("invalid attempt to set value of section symbol");
3223 symbolS
*s
= exp
.X_add_symbol
;
3225 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3226 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3228 S_SET_EXTERNAL (symbolP
);
3230 S_CLEAR_EXTERNAL (symbolP
);
3231 #endif /* OBJ_AOUT or OBJ_BOUT */
3232 S_SET_VALUE (symbolP
,
3233 exp
.X_add_number
+ S_GET_VALUE (s
));
3234 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3235 copy_symbol_attributes (symbolP
, s
);
3240 /* The value is some complex expression. */
3241 symbol_set_value_expression (symbolP
, &exp
);
3242 S_SET_SEGMENT (symbolP
, seg
);
3249 CONStruct more frag of .bytes, or .words etc.
3250 Should need_pass_2 be 1 then emit no frag(s).
3251 This understands EXPRESSIONS.
3255 This has a split personality. We use expression() to read the
3256 value. We can detect if the value won't fit in a byte or word.
3257 But we can't detect if expression() discarded significant digits
3258 in the case of a long. Not worth the crocks required to fix it. */
3260 /* Select a parser for cons expressions. */
3262 /* Some targets need to parse the expression in various fancy ways.
3263 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3264 (for example, the HPPA does this). Otherwise, you can define
3265 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3266 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3267 are defined, which is the normal case, then only simple expressions
3272 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3275 #ifndef TC_PARSE_CONS_EXPRESSION
3276 #ifdef BITFIELD_CONS_EXPRESSIONS
3277 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3279 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3281 #ifdef REPEAT_CONS_EXPRESSIONS
3282 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3284 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3287 /* If we haven't gotten one yet, just call expression. */
3288 #ifndef TC_PARSE_CONS_EXPRESSION
3289 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3293 /* Worker to do .byte etc statements.
3294 Clobbers input_line_pointer and checks end-of-line. */
3297 cons_worker (nbytes
, rva
)
3298 register int nbytes
; /* 1=.byte, 2=.word, 4=.long. */
3306 #ifdef md_flush_pending_output
3307 md_flush_pending_output ();
3311 stop
= mri_comment_field (&stopc
);
3313 if (is_it_end_of_statement ())
3315 demand_empty_rest_of_line ();
3317 mri_comment_end (stop
, stopc
);
3321 #ifdef md_cons_align
3322 md_cons_align (nbytes
);
3330 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3333 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3337 if (exp
.X_op
== O_symbol
)
3338 exp
.X_op
= O_symbol_rva
;
3340 as_fatal (_("rva without symbol"));
3342 emit_expr (&exp
, (unsigned int) nbytes
);
3345 while (*input_line_pointer
++ == ',');
3347 /* In MRI mode, after an odd number of bytes, we must align to an
3348 even word boundary, unless the next instruction is a dc.b, ds.b
3350 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3351 mri_pending_align
= 1;
3353 input_line_pointer
--; /* Put terminator back into stream. */
3355 demand_empty_rest_of_line ();
3358 mri_comment_end (stop
, stopc
);
3365 cons_worker (size
, 0);
3372 cons_worker (size
, 1);
3375 /* Put the contents of expression EXP into the object file using
3376 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3379 emit_expr (exp
, nbytes
)
3381 unsigned int nbytes
;
3385 valueT extra_digit
= 0;
3387 /* Don't do anything if we are going to make another pass. */
3393 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3394 appear as a four byte positive constant in the .line section,
3395 followed by a 2 byte 0xffff. Look for that case here. */
3397 static int dwarf_line
= -1;
3399 if (strcmp (segment_name (now_seg
), ".line") != 0)
3401 else if (dwarf_line
>= 0
3403 && exp
->X_op
== O_constant
3404 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3405 listing_source_line ((unsigned int) dwarf_line
);
3406 else if (nbytes
== 4
3407 && exp
->X_op
== O_constant
3408 && exp
->X_add_number
>= 0)
3409 dwarf_line
= exp
->X_add_number
;
3414 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3415 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3416 AT_sibling (0x12) followed by a four byte address of the sibling
3417 followed by a 2 byte AT_name (0x38) followed by the name of the
3418 file. We look for that case here. */
3420 static int dwarf_file
= 0;
3422 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3424 else if (dwarf_file
== 0
3426 && exp
->X_op
== O_constant
3427 && exp
->X_add_number
== 0x11)
3429 else if (dwarf_file
== 1
3431 && exp
->X_op
== O_constant
3432 && exp
->X_add_number
== 0x12)
3434 else if (dwarf_file
== 2
3437 else if (dwarf_file
== 3
3439 && exp
->X_op
== O_constant
3440 && exp
->X_add_number
== 0x38)
3445 /* The variable dwarf_file_string tells stringer that the string
3446 may be the name of the source file. */
3447 if (dwarf_file
== 4)
3448 dwarf_file_string
= 1;
3450 dwarf_file_string
= 0;
3455 if (check_eh_frame (exp
, &nbytes
))
3460 /* Allow `.word 0' in the absolute section. */
3461 if (now_seg
== absolute_section
)
3463 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3464 as_bad (_("attempt to store value in absolute section"));
3465 abs_section_offset
+= nbytes
;
3469 /* Handle a negative bignum. */
3471 && exp
->X_add_number
== 0
3472 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3473 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3476 unsigned long carry
;
3478 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3480 /* Negate the bignum: one's complement each digit and add 1. */
3482 for (i
= 0; i
< exp
->X_add_number
; i
++)
3486 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3489 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3490 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3493 /* We can ignore any carry out, because it will be handled by
3494 extra_digit if it is needed. */
3496 extra_digit
= (valueT
) -1;
3500 if (op
== O_absent
|| op
== O_illegal
)
3502 as_warn (_("zero assumed for missing expression"));
3503 exp
->X_add_number
= 0;
3506 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3508 as_bad (_("floating point number invalid; zero assumed"));
3509 exp
->X_add_number
= 0;
3512 else if (op
== O_register
)
3514 as_warn (_("register value used as expression"));
3518 p
= frag_more ((int) nbytes
);
3520 #ifndef WORKING_DOT_WORD
3521 /* If we have the difference of two symbols in a word, save it on
3522 the broken_words list. See the code in write.c. */
3523 if (op
== O_subtract
&& nbytes
== 2)
3525 struct broken_word
*x
;
3527 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3528 x
->next_broken_word
= broken_words
;
3531 x
->subseg
= now_subseg
;
3533 x
->word_goes_here
= p
;
3535 x
->add
= exp
->X_add_symbol
;
3536 x
->sub
= exp
->X_op_symbol
;
3537 x
->addnum
= exp
->X_add_number
;
3544 /* If we have an integer, but the number of bytes is too large to
3545 pass to md_number_to_chars, handle it as a bignum. */
3546 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3551 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3552 extra_digit
= (valueT
) -1;
3553 val
= (valueT
) exp
->X_add_number
;
3557 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3558 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3562 op
= exp
->X_op
= O_big
;
3563 exp
->X_add_number
= gencnt
;
3566 if (op
== O_constant
)
3568 register valueT get
;
3569 register valueT use
;
3570 register valueT mask
;
3572 register valueT unmask
;
3574 /* JF << of >= number of bits in the object is undefined. In
3575 particular SPARC (Sun 4) has problems. */
3576 if (nbytes
>= sizeof (valueT
))
3579 if (nbytes
> sizeof (valueT
))
3582 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3586 /* Don't store these bits. */
3587 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3588 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3591 unmask
= ~mask
; /* Do store these bits. */
3594 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3595 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3598 get
= exp
->X_add_number
;
3600 if ((get
& mask
) != 0
3601 && ((get
& mask
) != mask
3602 || (get
& hibit
) == 0))
3603 { /* Leading bits contain both 0s & 1s. */
3604 as_warn (_("Value 0x%lx truncated to 0x%lx."),
3605 (unsigned long) get
, (unsigned long) use
);
3607 /* Put bytes in right order. */
3608 md_number_to_chars (p
, use
, (int) nbytes
);
3610 else if (op
== O_big
)
3613 LITTLENUM_TYPE
*nums
;
3615 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3617 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3620 as_warn (_("Bignum truncated to %d bytes"), nbytes
);
3624 if (target_big_endian
)
3626 while (nbytes
> size
)
3628 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3629 nbytes
-= CHARS_PER_LITTLENUM
;
3630 p
+= CHARS_PER_LITTLENUM
;
3633 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3637 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3638 size
-= CHARS_PER_LITTLENUM
;
3639 p
+= CHARS_PER_LITTLENUM
;
3644 nums
= generic_bignum
;
3647 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3649 size
-= CHARS_PER_LITTLENUM
;
3650 p
+= CHARS_PER_LITTLENUM
;
3651 nbytes
-= CHARS_PER_LITTLENUM
;
3656 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3657 nbytes
-= CHARS_PER_LITTLENUM
;
3658 p
+= CHARS_PER_LITTLENUM
;
3664 memset (p
, 0, nbytes
);
3666 /* Now we need to generate a fixS to record the symbol value.
3667 This is easy for BFD. For other targets it can be more
3668 complex. For very complex cases (currently, the HPPA and
3669 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3670 want. For simpler cases, you can define TC_CONS_RELOC to be
3671 the name of the reloc code that should be stored in the fixS.
3672 If neither is defined, the code uses NO_RELOC if it is
3673 defined, and otherwise uses 0. */
3675 #ifdef BFD_ASSEMBLER
3676 #ifdef TC_CONS_FIX_NEW
3677 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3680 bfd_reloc_code_real_type r
;
3697 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3701 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3706 #ifdef TC_CONS_FIX_NEW
3707 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3709 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3710 it is defined, otherwise use NO_RELOC if it is defined,
3712 #ifndef TC_CONS_RELOC
3714 #define TC_CONS_RELOC NO_RELOC
3716 #define TC_CONS_RELOC 0
3719 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3721 #endif /* TC_CONS_FIX_NEW */
3722 #endif /* BFD_ASSEMBLER */
3726 #ifdef BITFIELD_CONS_EXPRESSIONS
3728 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3729 w:x,y:z, where w and y are bitwidths and x and y are values. They
3730 then pack them all together. We do a little better in that we allow
3731 them in words, longs, etc. and we'll pack them in target byte order
3734 The rules are: pack least significat bit first, if a field doesn't
3735 entirely fit, put it in the next unit. Overflowing the bitfield is
3736 explicitly *not* even a warning. The bitwidth should be considered
3739 To use this function the tc-XXX.h file should define
3740 BITFIELD_CONS_EXPRESSIONS. */
3743 parse_bitfield_cons (exp
, nbytes
)
3745 unsigned int nbytes
;
3747 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3748 char *hold
= input_line_pointer
;
3750 (void) expression (exp
);
3752 if (*input_line_pointer
== ':')
3759 unsigned long width
;
3761 if (*input_line_pointer
!= ':')
3763 input_line_pointer
= hold
;
3765 } /* Next piece is not a bitfield. */
3767 /* In the general case, we can't allow
3768 full expressions with symbol
3769 differences and such. The relocation
3770 entries for symbols not defined in this
3771 assembly would require arbitrary field
3772 widths, positions, and masks which most
3773 of our current object formats don't
3776 In the specific case where a symbol
3777 *is* defined in this assembly, we
3778 *could* build fixups and track it, but
3779 this could lead to confusion for the
3780 backends. I'm lazy. I'll take any
3781 SEG_ABSOLUTE. I think that means that
3782 you can use a previous .set or
3783 .equ type symbol. xoxorich. */
3785 if (exp
->X_op
== O_absent
)
3787 as_warn (_("using a bit field width of zero"));
3788 exp
->X_add_number
= 0;
3789 exp
->X_op
= O_constant
;
3790 } /* Implied zero width bitfield. */
3792 if (exp
->X_op
!= O_constant
)
3794 *input_line_pointer
= '\0';
3795 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3796 *input_line_pointer
= ':';
3797 demand_empty_rest_of_line ();
3799 } /* Too complex. */
3801 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3803 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3804 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3805 width
= BITS_PER_CHAR
* nbytes
;
3808 if (width
> bits_available
)
3810 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3811 input_line_pointer
= hold
;
3812 exp
->X_add_number
= value
;
3817 hold
= ++input_line_pointer
;
3819 (void) expression (exp
);
3820 if (exp
->X_op
!= O_constant
)
3822 char cache
= *input_line_pointer
;
3824 *input_line_pointer
= '\0';
3825 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3826 *input_line_pointer
= cache
;
3827 demand_empty_rest_of_line ();
3829 } /* Too complex. */
3831 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3832 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3834 if ((bits_available
-= width
) == 0
3835 || is_it_end_of_statement ()
3836 || *input_line_pointer
!= ',')
3839 } /* All the bitfields we're gonna get. */
3841 hold
= ++input_line_pointer
;
3842 (void) expression (exp
);
3845 exp
->X_add_number
= value
;
3846 exp
->X_op
= O_constant
;
3847 exp
->X_unsigned
= 1;
3851 #endif /* BITFIELD_CONS_EXPRESSIONS */
3853 /* Handle an MRI style string expression. */
3857 parse_mri_cons (exp
, nbytes
)
3859 unsigned int nbytes
;
3861 if (*input_line_pointer
!= '\''
3862 && (input_line_pointer
[1] != '\''
3863 || (*input_line_pointer
!= 'A'
3864 && *input_line_pointer
!= 'E')))
3865 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3869 unsigned int result
= 0;
3871 /* An MRI style string. Cut into as many bytes as will fit into
3872 a nbyte chunk, left justify if necessary, and separate with
3873 commas so we can try again later. */
3874 if (*input_line_pointer
== 'A')
3875 ++input_line_pointer
;
3876 else if (*input_line_pointer
== 'E')
3878 as_bad (_("EBCDIC constants are not supported"));
3879 ++input_line_pointer
;
3882 input_line_pointer
++;
3883 for (scan
= 0; scan
< nbytes
; scan
++)
3885 if (*input_line_pointer
== '\'')
3887 if (input_line_pointer
[1] == '\'')
3889 input_line_pointer
++;
3894 result
= (result
<< 8) | (*input_line_pointer
++);
3898 while (scan
< nbytes
)
3904 /* Create correct expression. */
3905 exp
->X_op
= O_constant
;
3906 exp
->X_add_number
= result
;
3908 /* Fake it so that we can read the next char too. */
3909 if (input_line_pointer
[0] != '\'' ||
3910 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3912 input_line_pointer
-= 2;
3913 input_line_pointer
[0] = ',';
3914 input_line_pointer
[1] = '\'';
3917 input_line_pointer
++;
3920 #endif /* TC_M68K */
3922 #ifdef REPEAT_CONS_EXPRESSIONS
3924 /* Parse a repeat expression for cons. This is used by the MIPS
3925 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3926 object file COUNT times.
3928 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3931 parse_repeat_cons (exp
, nbytes
)
3933 unsigned int nbytes
;
3940 if (*input_line_pointer
!= ':')
3942 /* No repeat count. */
3946 ++input_line_pointer
;
3947 expression (&count
);
3948 if (count
.X_op
!= O_constant
3949 || count
.X_add_number
<= 0)
3951 as_warn (_("Unresolvable or nonpositive repeat count; using 1"));
3955 /* The cons function is going to output this expression once. So we
3956 output it count - 1 times. */
3957 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3958 emit_expr (exp
, nbytes
);
3961 #endif /* REPEAT_CONS_EXPRESSIONS */
3963 /* Parse a floating point number represented as a hex constant. This
3964 permits users to specify the exact bits they want in the floating
3968 hex_float (float_type
, bytes
)
4002 as_bad (_("Unknown floating type type '%c'"), float_type
);
4006 /* It would be nice if we could go through expression to parse the
4007 hex constant, but if we get a bignum it's a pain to sort it into
4008 the buffer correctly. */
4010 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4014 /* The MRI assembler accepts arbitrary underscores strewn about
4015 through the hex constant, so we ignore them as well. */
4016 if (*input_line_pointer
== '_')
4018 ++input_line_pointer
;
4024 as_warn (_("Floating point constant too large"));
4027 d
= hex_value (*input_line_pointer
) << 4;
4028 ++input_line_pointer
;
4029 while (*input_line_pointer
== '_')
4030 ++input_line_pointer
;
4031 if (hex_p (*input_line_pointer
))
4033 d
+= hex_value (*input_line_pointer
);
4034 ++input_line_pointer
;
4036 if (target_big_endian
)
4039 bytes
[length
- i
- 1] = d
;
4045 if (target_big_endian
)
4046 memset (bytes
+ i
, 0, length
- i
);
4048 memset (bytes
, 0, length
- i
);
4056 CONStruct some more frag chars of .floats .ffloats etc.
4057 Makes 0 or more new frags.
4058 If need_pass_2 == 1, no frags are emitted.
4059 This understands only floating literals, not expressions. Sorry.
4061 A floating constant is defined by atof_generic(), except it is preceded
4062 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4063 reading, I decided to be incompatible. This always tries to give you
4064 rounded bits to the precision of the pseudo-op. Former AS did premature
4065 truncatation, restored noisy bits instead of trailing 0s AND gave you
4066 a choice of 2 flavours of noise according to which of 2 floating-point
4067 scanners you directed AS to use.
4069 In: input_line_pointer->whitespace before, or '0' of flonum. */
4072 float_cons (float_type
)
4073 /* Clobbers input_line-pointer, checks end-of-line. */
4074 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4077 int length
; /* Number of chars in an object. */
4078 register char *err
; /* Error from scanning floating literal. */
4079 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4081 if (is_it_end_of_statement ())
4083 demand_empty_rest_of_line ();
4087 #ifdef md_flush_pending_output
4088 md_flush_pending_output ();
4093 /* input_line_pointer->1st char of a flonum (we hope!). */
4096 /* Skip any 0{letter} that may be present. Don't even check if the
4097 letter is legal. Someone may invent a "z" format and this routine
4098 has no use for such information. Lusers beware: you get
4099 diagnostics if your input is ill-conditioned. */
4100 if (input_line_pointer
[0] == '0'
4101 && isalpha ((unsigned char) input_line_pointer
[1]))
4102 input_line_pointer
+= 2;
4104 /* Accept :xxxx, where the x's are hex digits, for a floating
4105 point with the exact digits specified. */
4106 if (input_line_pointer
[0] == ':')
4108 ++input_line_pointer
;
4109 length
= hex_float (float_type
, temp
);
4112 ignore_rest_of_line ();
4118 err
= md_atof (float_type
, temp
, &length
);
4119 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4123 as_bad (_("Bad floating literal: %s"), err
);
4124 ignore_rest_of_line ();
4135 #ifdef REPEAT_CONS_EXPRESSIONS
4136 if (*input_line_pointer
== ':')
4138 expressionS count_exp
;
4140 ++input_line_pointer
;
4141 expression (&count_exp
);
4143 if (count_exp
.X_op
!= O_constant
4144 || count_exp
.X_add_number
<= 0)
4145 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4147 count
= count_exp
.X_add_number
;
4151 while (--count
>= 0)
4153 p
= frag_more (length
);
4154 memcpy (p
, temp
, (unsigned int) length
);
4159 while (*input_line_pointer
++ == ',');
4161 /* Put terminator back into stream. */
4162 --input_line_pointer
;
4163 demand_empty_rest_of_line ();
4166 /* Return the size of a LEB128 value. */
4169 sizeof_sleb128 (value
)
4172 register int size
= 0;
4173 register unsigned byte
;
4177 byte
= (value
& 0x7f);
4178 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4179 Fortunately, we can structure things so that the extra work reduces
4180 to a noop on systems that do things "properly". */
4181 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4184 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4185 || ((value
== -1) && ((byte
& 0x40) != 0))));
4191 sizeof_uleb128 (value
)
4194 register int size
= 0;
4195 register unsigned byte
;
4199 byte
= (value
& 0x7f);
4209 sizeof_leb128 (value
, sign
)
4214 return sizeof_sleb128 ((offsetT
) value
);
4216 return sizeof_uleb128 (value
);
4219 /* Output a LEB128 value. */
4222 output_sleb128 (p
, value
)
4226 register char *orig
= p
;
4231 unsigned byte
= (value
& 0x7f);
4233 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4234 Fortunately, we can structure things so that the extra work reduces
4235 to a noop on systems that do things "properly". */
4236 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4238 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4239 || ((value
== -1) && ((byte
& 0x40) != 0))));
4251 output_uleb128 (p
, value
)
4259 unsigned byte
= (value
& 0x7f);
4262 /* More bytes to follow. */
4273 output_leb128 (p
, value
, sign
)
4279 return output_sleb128 (p
, (offsetT
) value
);
4281 return output_uleb128 (p
, value
);
4284 /* Do the same for bignums. We combine sizeof with output here in that
4285 we don't output for NULL values of P. It isn't really as critical as
4286 for "normal" values that this be streamlined. */
4289 output_big_sleb128 (p
, bignum
, size
)
4291 LITTLENUM_TYPE
*bignum
;
4299 /* Strip leading sign extensions off the bignum. */
4300 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4305 if (loaded
< 7 && size
> 0)
4307 val
|= (*bignum
<< loaded
);
4308 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4319 if ((val
== 0 && (byte
& 0x40) == 0)
4320 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4321 && (byte
& 0x40) != 0))
4329 while (byte
& 0x80);
4335 output_big_uleb128 (p
, bignum
, size
)
4337 LITTLENUM_TYPE
*bignum
;
4345 /* Strip leading zeros off the bignum. */
4346 /* XXX: Is this needed? */
4347 while (size
> 0 && bignum
[size
- 1] == 0)
4352 if (loaded
< 7 && size
> 0)
4354 val
|= (*bignum
<< loaded
);
4355 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4364 if (size
> 0 || val
)
4371 while (byte
& 0x80);
4377 output_big_leb128 (p
, bignum
, size
, sign
)
4379 LITTLENUM_TYPE
*bignum
;
4383 return output_big_sleb128 (p
, bignum
, size
);
4385 return output_big_uleb128 (p
, bignum
, size
);
4388 /* Generate the appropriate fragments for a given expression to emit a
4392 emit_leb128_expr (exp
, sign
)
4396 operatorT op
= exp
->X_op
;
4399 if (op
== O_absent
|| op
== O_illegal
)
4401 as_warn (_("zero assumed for missing expression"));
4402 exp
->X_add_number
= 0;
4405 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4407 as_bad (_("floating point number invalid; zero assumed"));
4408 exp
->X_add_number
= 0;
4411 else if (op
== O_register
)
4413 as_warn (_("register value used as expression"));
4417 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
4418 a signal that this is leb128 data. It shouldn't optimize this away. */
4420 if (check_eh_frame (exp
, &nbytes
))
4423 if (op
== O_constant
)
4425 /* If we've got a constant, emit the thing directly right now. */
4427 valueT value
= exp
->X_add_number
;
4431 size
= sizeof_leb128 (value
, sign
);
4432 p
= frag_more (size
);
4433 output_leb128 (p
, value
, sign
);
4435 else if (op
== O_big
)
4437 /* O_big is a different sort of constant. */
4442 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4443 p
= frag_more (size
);
4444 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4448 /* Otherwise, we have to create a variable sized fragment and
4449 resolve things later. */
4451 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4452 make_expr_symbol (exp
), 0, (char *) NULL
);
4456 /* Parse the .sleb128 and .uleb128 pseudos. */
4467 emit_leb128_expr (&exp
, sign
);
4469 while (*input_line_pointer
++ == ',');
4471 input_line_pointer
--;
4472 demand_empty_rest_of_line ();
4475 /* We read 0 or more ',' separated, double-quoted strings.
4476 Caller should have checked need_pass_2 is FALSE because we don't
4480 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4481 /* Checks end-of-line. */
4482 register int append_zero
; /* 0: don't append '\0', else 1. */
4484 register unsigned int c
;
4487 #ifdef md_flush_pending_output
4488 md_flush_pending_output ();
4491 /* The following awkward logic is to parse ZERO or more strings,
4492 comma separated. Recall a string expression includes spaces
4493 before the opening '\"' and spaces after the closing '\"'.
4494 We fake a leading ',' if there is (supposed to be)
4495 a 1st, expression. We keep demanding expressions for each ','. */
4496 if (is_it_end_of_statement ())
4498 c
= 0; /* Skip loop. */
4499 ++input_line_pointer
; /* Compensate for end of loop. */
4503 c
= ','; /* Do loop. */
4505 while (c
== ',' || c
== '<' || c
== '"')
4508 switch (*input_line_pointer
)
4511 ++input_line_pointer
; /*->1st char of string. */
4512 start
= input_line_pointer
;
4513 while (is_a_char (c
= next_char_of_string ()))
4515 FRAG_APPEND_1_CHAR (c
);
4519 FRAG_APPEND_1_CHAR (0);
4521 know (input_line_pointer
[-1] == '\"');
4525 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4526 will emit .string with a filename in the .debug section
4527 after a sequence of constants. See the comment in
4528 emit_expr for the sequence. emit_expr will set
4529 dwarf_file_string to non-zero if this string might be a
4530 source file name. */
4531 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4532 dwarf_file_string
= 0;
4533 else if (dwarf_file_string
)
4535 c
= input_line_pointer
[-1];
4536 input_line_pointer
[-1] = '\0';
4537 listing_source_file (start
);
4538 input_line_pointer
[-1] = c
;
4545 input_line_pointer
++;
4546 c
= get_single_number ();
4547 FRAG_APPEND_1_CHAR (c
);
4548 if (*input_line_pointer
!= '>')
4550 as_bad (_("Expected <nn>"));
4552 input_line_pointer
++;
4555 input_line_pointer
++;
4559 c
= *input_line_pointer
;
4562 demand_empty_rest_of_line ();
4565 /* FIXME-SOMEDAY: I had trouble here on characters with the
4566 high bits set. We'll probably also have trouble with
4567 multibyte chars, wide chars, etc. Also be careful about
4568 returning values bigger than 1 byte. xoxorich. */
4571 next_char_of_string ()
4573 register unsigned int c
;
4575 c
= *input_line_pointer
++ & CHAR_MASK
;
4583 as_warn (_("Unterminated string: Newline inserted."));
4584 bump_line_counters ();
4587 #ifndef NO_STRING_ESCAPES
4589 switch (c
= *input_line_pointer
++)
4617 break; /* As itself. */
4633 for (i
= 0, number
= 0;
4634 isdigit (c
) && i
< 3;
4635 c
= *input_line_pointer
++, i
++)
4637 number
= number
* 8 + c
- '0';
4642 --input_line_pointer
;
4651 c
= *input_line_pointer
++;
4652 while (isxdigit (c
))
4655 number
= number
* 16 + c
- '0';
4656 else if (isupper (c
))
4657 number
= number
* 16 + c
- 'A' + 10;
4659 number
= number
* 16 + c
- 'a' + 10;
4660 c
= *input_line_pointer
++;
4663 --input_line_pointer
;
4668 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4669 as_warn (_("Unterminated string: Newline inserted."));
4671 bump_line_counters ();
4676 #ifdef ONLY_STANDARD_ESCAPES
4677 as_bad (_("Bad escaped character in string, '?' assumed"));
4679 #endif /* ONLY_STANDARD_ESCAPES */
4684 #endif /* ! defined (NO_STRING_ESCAPES) */
4693 get_segmented_expression (expP
)
4694 register expressionS
*expP
;
4696 register segT retval
;
4698 retval
= expression (expP
);
4699 if (expP
->X_op
== O_illegal
4700 || expP
->X_op
== O_absent
4701 || expP
->X_op
== O_big
)
4703 as_bad (_("expected address expression; zero assumed"));
4704 expP
->X_op
= O_constant
;
4705 expP
->X_add_number
= 0;
4706 retval
= absolute_section
;
4712 get_known_segmented_expression (expP
)
4713 register expressionS
*expP
;
4715 register segT retval
;
4717 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4719 /* There is no easy way to extract the undefined symbol from the
4721 if (expP
->X_add_symbol
!= NULL
4722 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4723 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4724 S_GET_NAME (expP
->X_add_symbol
));
4726 as_warn (_("some symbol undefined; zero assumed"));
4727 retval
= absolute_section
;
4728 expP
->X_op
= O_constant
;
4729 expP
->X_add_number
= 0;
4731 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4736 get_absolute_expression ()
4741 if (exp
.X_op
!= O_constant
)
4743 if (exp
.X_op
!= O_absent
)
4744 as_bad (_("bad or irreducible absolute expression; zero assumed"));
4745 exp
.X_add_number
= 0;
4747 return exp
.X_add_number
;
4750 char /* Return terminator. */
4751 get_absolute_expression_and_terminator (val_pointer
)
4752 long *val_pointer
; /* Return value of expression. */
4754 /* FIXME: val_pointer should probably be offsetT *. */
4755 *val_pointer
= (long) get_absolute_expression ();
4756 return (*input_line_pointer
++);
4759 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4760 Give a warning if that happens. */
4763 demand_copy_C_string (len_pointer
)
4768 if ((s
= demand_copy_string (len_pointer
)) != 0)
4772 for (len
= *len_pointer
; len
> 0; len
--)
4779 as_bad (_("This string may not contain \'\\0\'"));
4787 /* Demand string, but return a safe (=private) copy of the string.
4788 Return NULL if we can't read a string here. */
4791 demand_copy_string (lenP
)
4794 register unsigned int c
;
4800 if (*input_line_pointer
== '\"')
4802 input_line_pointer
++; /* Skip opening quote. */
4804 while (is_a_char (c
= next_char_of_string ()))
4806 obstack_1grow (¬es
, c
);
4809 /* JF this next line is so demand_copy_C_string will return a
4810 null terminated string. */
4811 obstack_1grow (¬es
, '\0');
4812 retval
= obstack_finish (¬es
);
4816 as_warn (_("Missing string"));
4818 ignore_rest_of_line ();
4824 /* In: Input_line_pointer->next character.
4826 Do: Skip input_line_pointer over all whitespace.
4828 Out: 1 if input_line_pointer->end-of-line. */
4831 is_it_end_of_statement ()
4834 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4838 equals (sym_name
, reassign
)
4842 register symbolS
*symbolP
; /* Symbol we are working with. */
4846 input_line_pointer
++;
4847 if (*input_line_pointer
== '=')
4848 input_line_pointer
++;
4850 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4851 input_line_pointer
++;
4854 stop
= mri_comment_field (&stopc
);
4856 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4858 /* Turn '. = mumble' into a .org mumble. */
4859 register segT segment
;
4862 segment
= get_known_segmented_expression (&exp
);
4864 do_org (segment
, &exp
, 0);
4871 symbolP
= symbol_find (sym_name
);
4872 local
= symbolP
== NULL
;
4874 #endif /* OBJ_COFF */
4875 symbolP
= symbol_find_or_make (sym_name
);
4876 /* Permit register names to be redefined. */
4878 && S_IS_DEFINED (symbolP
)
4879 && S_GET_SEGMENT (symbolP
) != reg_section
)
4880 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
4883 /* "set" symbols are local unless otherwise specified. */
4885 SF_SET_LOCAL (symbolP
);
4886 #endif /* OBJ_COFF */
4888 pseudo_set (symbolP
);
4893 /* Check garbage after the expression. */
4894 ignore_rest_of_line ();
4895 mri_comment_end (stop
, stopc
);
4899 /* .include -- include a file at this point. */
4903 int arg ATTRIBUTE_UNUSED
;
4912 filename
= demand_copy_string (&i
);
4913 if (filename
== NULL
)
4915 /* demand_copy_string has already printed an error and
4916 called ignore_rest_of_line. */
4924 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
4925 && *input_line_pointer
!= ' '
4926 && *input_line_pointer
!= '\t')
4928 obstack_1grow (¬es
, *input_line_pointer
);
4929 ++input_line_pointer
;
4933 obstack_1grow (¬es
, '\0');
4934 filename
= obstack_finish (¬es
);
4935 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
4936 ++input_line_pointer
;
4939 demand_empty_rest_of_line ();
4940 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
4942 for (i
= 0; i
< include_dir_count
; i
++)
4944 strcpy (path
, include_dirs
[i
]);
4946 strcat (path
, filename
);
4947 if (0 != (try = fopen (path
, "r")))
4957 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
4958 register_dependency (path
);
4959 input_scrub_insert_file (path
);
4963 add_include_dir (path
)
4968 if (include_dir_count
== 0)
4970 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
4971 include_dirs
[0] = "."; /* Current dir. */
4972 include_dir_count
= 2;
4976 include_dir_count
++;
4978 (char **) realloc (include_dirs
,
4979 include_dir_count
* sizeof (*include_dirs
));
4982 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
4985 if (i
> include_dir_maxlen
)
4986 include_dir_maxlen
= i
;
4989 /* Output debugging information to denote the source file. */
4992 generate_file_debug ()
4994 if (debug_type
== DEBUG_STABS
)
4995 stabs_generate_asm_file ();
4998 /* Output line number debugging information for the current source line. */
5001 generate_lineno_debug ()
5005 case DEBUG_UNSPECIFIED
:
5010 stabs_generate_asm_lineno ();
5013 ecoff_generate_asm_lineno ();
5016 /* ??? We could here indicate to dwarf2dbg.c that something
5017 has changed. However, since there is additional backend
5018 support that is required (calling dwarf2_emit_insn), we
5019 let dwarf2dbg.c call as_where on its own. */
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
);