1 /* read.c - read a source file -
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001 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 {"incbin", s_incbin
, 0},
353 {"include", s_include
, 0},
359 {"lcomm", s_lcomm
, 0},
360 {"lflags", listing_flags
, 0}, /* Listing flags. */
361 {"linkonce", s_linkonce
, 0},
362 {"list", listing_list
, 1}, /* Turn listing on. */
363 {"llen", listing_psize
, 1},
366 {"macro", s_macro
, 0},
367 {"mexit", s_mexit
, 0},
369 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
370 {"name", s_ignore
, 0},
371 {"noformat", s_ignore
, 0},
372 {"nolist", listing_list
, 0}, /* Turn listing off. */
373 {"nopage", listing_nopage
, 0},
375 {"offset", s_struct
, 0},
377 {"p2align", s_align_ptwo
, 0},
378 {"p2alignw", s_align_ptwo
, -2},
379 {"p2alignl", s_align_ptwo
, -4},
380 {"page", listing_eject
, 0},
381 {"plen", listing_psize
, 0},
382 {"print", s_print
, 0},
383 {"psize", listing_psize
, 0}, /* Set paper size. */
384 {"purgem", s_purgem
, 0},
389 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
394 {"single", float_cons
, 'f'},
396 {"space", s_space
, 0},
397 {"skip", s_space
, 0},
398 {"sleb128", s_leb128
, 1},
399 {"spc", s_ignore
, 0},
400 {"stabd", s_stab
, 'd'},
401 {"stabn", s_stab
, 'n'},
402 {"stabs", s_stab
, 's'},
403 {"string", stringer
, 1},
404 {"struct", s_struct
, 0},
408 /* This is for gcc to use. It's only just been added (2/94), so gcc
409 won't be able to use it for a while -- probably a year or more.
410 But once this has been released, check with gcc maintainers
411 before deleting it or even changing the spelling. */
412 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
413 /* If we're folding case -- done for some targets, not necessarily
414 all -- the above string in an input file will be converted to
415 this one. Match it either way... */
416 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
418 {"title", listing_title
, 0}, /* Listing title. */
419 {"ttl", listing_title
, 0},
421 {"uleb128", s_leb128
, 0},
425 {"xdef", s_globl
, 0},
426 {"xref", s_ignore
, 0},
427 {"xstabs", s_xstab
, 's'},
429 {"zero", s_space
, 0},
430 {NULL
, NULL
, 0} /* End sentinel. */
433 static int pop_override_ok
= 0;
434 static const char *pop_table_name
;
438 const pseudo_typeS
*table
;
441 const pseudo_typeS
*pop
;
442 for (pop
= table
; pop
->poc_name
; pop
++)
444 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
445 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
446 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
451 #ifndef md_pop_insert
452 #define md_pop_insert() pop_insert(md_pseudo_table)
455 #ifndef obj_pop_insert
456 #define obj_pop_insert() pop_insert(obj_pseudo_table)
462 po_hash
= hash_new ();
464 /* Do the target-specific pseudo ops. */
465 pop_table_name
= "md";
468 /* Now object specific. Skip any that were in the target table. */
469 pop_table_name
= "obj";
473 /* Now portable ones. Skip any that we've seen already. */
474 pop_table_name
= "standard";
475 pop_insert (potable
);
478 #define HANDLE_CONDITIONAL_ASSEMBLY() \
479 if (ignore_input ()) \
481 while (!is_end_of_line[(unsigned char) *input_line_pointer++]) \
482 if (input_line_pointer == buffer_limit) \
487 /* This function is used when scrubbing the characters between #APP
490 static char *scrub_string
;
491 static char *scrub_string_end
;
494 scrub_from_string (buf
, buflen
)
500 copy
= scrub_string_end
- scrub_string
;
503 memcpy (buf
, scrub_string
, copy
);
504 scrub_string
+= copy
;
508 /* We read the file, putting things into a web that represents what we
509 have been reading. */
511 read_a_source_file (name
)
515 register char *s
; /* String of symbol, '\0' appended. */
523 buffer
= input_scrub_new_file (name
);
526 listing_newline (NULL
);
527 register_dependency (name
);
529 /* Generate debugging information before we've read anything in to denote
530 this file as the "main" source file and not a subordinate one
531 (e.g. N_SO vs N_SOL in stabs). */
532 generate_file_debug ();
534 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
535 { /* We have another line to parse. */
536 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
537 contin
: /* JF this goto is my fault I admit it.
538 Someone brave please re-write the whole
539 input section here? Pleeze??? */
540 while (input_line_pointer
< buffer_limit
)
542 /* We have more of this buffer to parse. */
544 /* We now have input_line_pointer->1st char of next line.
545 If input_line_pointer [-1] == '\n' then we just
546 scanned another line: so bump line counters. */
547 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
549 #ifdef md_start_line_hook
550 md_start_line_hook ();
552 if (input_line_pointer
[-1] == '\n')
553 bump_line_counters ();
557 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
559 /* Text at the start of a line must be a label, we
560 run down and stick a colon in. */
561 if (is_name_beginner (*input_line_pointer
))
563 char *line_start
= input_line_pointer
;
568 HANDLE_CONDITIONAL_ASSEMBLY ();
570 c
= get_symbol_end ();
572 /* In MRI mode, the EQU and MACRO pseudoops must
573 be handled specially. */
577 char *rest
= input_line_pointer
+ 1;
581 if (*rest
== ' ' || *rest
== '\t')
583 if ((strncasecmp (rest
, "EQU", 3) == 0
584 || strncasecmp (rest
, "SET", 3) == 0)
585 && (rest
[3] == ' ' || rest
[3] == '\t'))
587 input_line_pointer
= rest
+ 3;
589 strncasecmp (rest
, "SET", 3) == 0);
592 if (strncasecmp (rest
, "MACRO", 5) == 0
595 || is_end_of_line
[(unsigned char) rest
[5]]))
599 /* In MRI mode, we need to handle the MACRO
600 pseudo-op specially: we don't want to put the
601 symbol in the symbol table. */
603 #ifdef TC_START_LABEL_WITHOUT_COLON
604 && TC_START_LABEL_WITHOUT_COLON(c
,
608 line_label
= colon (line_start
);
610 line_label
= symbol_create (line_start
,
615 *input_line_pointer
= c
;
617 input_line_pointer
++;
622 /* We are at the begining of a line, or similar place.
623 We expect a well-formed assembler statement.
624 A "symbol-name:" is a statement.
626 Depending on what compiler is used, the order of these tests
627 may vary to catch most common case 1st.
628 Each test is independent of all other tests at the (top) level.
629 PLEASE make a compiler that doesn't use this assembler.
630 It is crufty to waste a compiler's time encoding things for this
631 assembler, which then wastes more time decoding it.
632 (And communicating via (linear) files is silly!
633 If you must pass stuff, please pass a tree!) */
634 if ((c
= *input_line_pointer
++) == '\t'
638 c
= *input_line_pointer
++;
640 know (c
!= ' '); /* No further leading whitespace. */
643 /* If listing is on, and we are expanding a macro, then give
644 the listing code the contents of the expanded line. */
647 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
652 /* Find the end of the current expanded macro line. */
653 for (s
= input_line_pointer
- 1; *s
; ++s
)
654 if (is_end_of_line
[(unsigned char) *s
])
657 /* Copy it for safe keeping. Also give an indication of
658 how much macro nesting is involved at this point. */
659 len
= s
- (input_line_pointer
- 1);
660 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
661 memset (copy
, '>', macro_nest
);
662 copy
[macro_nest
] = ' ';
663 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
- 1, len
);
664 copy
[macro_nest
+ 1 + len
] = '\0';
666 /* Install the line with the listing facility. */
667 listing_newline (copy
);
670 listing_newline (NULL
);
673 /* C is the 1st significant character.
674 Input_line_pointer points after that character. */
675 if (is_name_beginner (c
))
677 /* Want user-defined label or pseudo/opcode. */
678 HANDLE_CONDITIONAL_ASSEMBLY ();
680 s
= --input_line_pointer
;
681 c
= get_symbol_end (); /* name's delimiter. */
683 /* C is character after symbol.
684 That character's place in the input line is now '\0'.
685 S points to the beginning of the symbol.
686 [In case of pseudo-op, s->'.'.]
687 Input_line_pointer->'\0' where c was. */
688 if (TC_START_LABEL (c
, input_line_pointer
))
692 char *rest
= input_line_pointer
+ 1;
694 /* In MRI mode, \tsym: set 0 is permitted. */
698 if (*rest
== ' ' || *rest
== '\t')
701 if ((strncasecmp (rest
, "EQU", 3) == 0
702 || strncasecmp (rest
, "SET", 3) == 0)
703 && (rest
[3] == ' ' || rest
[3] == '\t'))
705 input_line_pointer
= rest
+ 3;
711 line_label
= colon (s
); /* User-defined label. */
712 /* Put ':' back for error messages' sake. */
713 *input_line_pointer
++ = ':';
714 /* Input_line_pointer->after ':'. */
718 || ((c
== ' ' || c
== '\t')
719 && input_line_pointer
[1] == '='
720 #ifdef TC_EQUAL_IN_INSN
721 && !TC_EQUAL_IN_INSN (c
, input_line_pointer
)
726 demand_empty_rest_of_line ();
730 /* Expect pseudo-op or machine instruction. */
733 #ifdef IGNORE_OPCODE_CASE
737 strncpy (original_case_string
, s2
, sizeof (original_case_string
));
738 original_case_string
[sizeof (original_case_string
) - 1] = 0;
742 if (isupper ((unsigned char) *s2
))
748 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
750 /* The MRI assembler and the m88k use pseudo-ops
752 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
753 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
758 || (!flag_m68k_mri
&& *s
== '.'))
762 WARNING: c has next char, which may be end-of-line.
763 We lookup the pseudo-op table with s+1 because we
764 already know that the pseudo-op begins with a '.'. */
767 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
769 /* In MRI mode, we may need to insert an
770 automatic alignment directive. What a hack
772 if (mri_pending_align
774 || !((pop
->poc_handler
== cons
775 && pop
->poc_val
== 1)
776 || (pop
->poc_handler
== s_space
777 && pop
->poc_val
== 1)
778 #ifdef tc_conditional_pseudoop
779 || tc_conditional_pseudoop (pop
)
781 || pop
->poc_handler
== s_if
782 || pop
->poc_handler
== s_ifdef
783 || pop
->poc_handler
== s_ifc
784 || pop
->poc_handler
== s_ifeqs
785 || pop
->poc_handler
== s_else
786 || pop
->poc_handler
== s_endif
787 || pop
->poc_handler
== s_globl
788 || pop
->poc_handler
== s_ignore
)))
790 do_align (1, (char *) NULL
, 0, 0);
791 mri_pending_align
= 0;
793 if (line_label
!= NULL
)
795 symbol_set_frag (line_label
, frag_now
);
796 S_SET_VALUE (line_label
, frag_now_fix ());
800 /* Print the error msg now, while we still can. */
803 as_bad (_("unknown pseudo-op: `%s'"), s
);
804 *input_line_pointer
= c
;
809 /* Put it back for error messages etc. */
810 *input_line_pointer
= c
;
811 /* The following skip of whitespace is compulsory.
812 A well shaped space is sometimes all that separates
813 keyword from operands. */
814 if (c
== ' ' || c
== '\t')
815 input_line_pointer
++;
817 /* Input_line is restored.
818 Input_line_pointer->1st non-blank char
819 after pseudo-operation. */
820 (*pop
->poc_handler
) (pop
->poc_val
);
822 /* If that was .end, just get out now. */
823 if (pop
->poc_handler
== s_end
)
829 #ifdef QUOTES_IN_INSN
833 /* WARNING: c has char, which may be end-of-line. */
834 /* Also: input_line_pointer->`\0` where c was. */
835 *input_line_pointer
= c
;
836 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
838 #ifdef TC_EOL_IN_INSN
839 || TC_EOL_IN_INSN (input_line_pointer
)
843 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
845 #ifdef QUOTES_IN_INSN
848 else if (*input_line_pointer
== '"')
850 else if (*input_line_pointer
== '\\')
853 input_line_pointer
++;
856 c
= *input_line_pointer
;
857 *input_line_pointer
= '\0';
859 generate_lineno_debug ();
867 if (check_macro (s
, &out
, '\0', &err
, ¯o
))
871 *input_line_pointer
++ = c
;
872 input_scrub_include_sb (&out
,
873 input_line_pointer
, 1);
876 input_scrub_next_buffer (&input_line_pointer
);
878 md_macro_info (macro
);
884 if (mri_pending_align
)
886 do_align (1, (char *) NULL
, 0, 0);
887 mri_pending_align
= 0;
888 if (line_label
!= NULL
)
890 symbol_set_frag (line_label
, frag_now
);
891 S_SET_VALUE (line_label
, frag_now_fix ());
895 md_assemble (s
); /* Assemble 1 instruction. */
897 *input_line_pointer
++ = c
;
899 /* We resume loop AFTER the end-of-line from
906 /* Empty statement? */
907 if (is_end_of_line
[(unsigned char) c
])
910 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
911 && isdigit ((unsigned char) c
))
913 /* local label ("4:") */
914 char *backup
= input_line_pointer
;
916 HANDLE_CONDITIONAL_ASSEMBLY ();
920 /* Read the whole number. */
921 while (isdigit ((unsigned char) *input_line_pointer
))
923 temp
= (temp
* 10) + *input_line_pointer
- '0';
924 ++input_line_pointer
;
927 if (LOCAL_LABELS_DOLLAR
928 && *input_line_pointer
== '$'
929 && *(input_line_pointer
+ 1) == ':')
931 input_line_pointer
+= 2;
933 if (dollar_label_defined (temp
))
935 as_fatal (_("label \"%d$\" redefined"), temp
);
938 define_dollar_label (temp
);
939 colon (dollar_label_name (temp
, 0));
944 && *input_line_pointer
++ == ':')
946 fb_label_instance_inc (temp
);
947 colon (fb_label_name (temp
, 0));
951 input_line_pointer
= backup
;
952 } /* local label ("4:") */
954 if (c
&& strchr (line_comment_chars
, c
))
955 { /* Its a comment. Better say APP or NO_APP. */
959 unsigned int new_length
;
962 bump_line_counters ();
963 s
= input_line_pointer
;
964 if (strncmp (s
, "APP\n", 4))
965 continue; /* We ignore it */
968 ends
= strstr (s
, "#NO_APP\n");
972 unsigned int tmp_len
;
975 /* The end of the #APP wasn't in this buffer. We
976 keep reading in buffers until we find the #NO_APP
977 that goes with this #APP There is one. The specs
979 tmp_len
= buffer_limit
- s
;
980 tmp_buf
= xmalloc (tmp_len
+ 1);
981 memcpy (tmp_buf
, s
, tmp_len
);
984 new_tmp
= input_scrub_next_buffer (&buffer
);
988 buffer_limit
= new_tmp
;
989 input_line_pointer
= buffer
;
990 ends
= strstr (buffer
, "#NO_APP\n");
994 num
= buffer_limit
- buffer
;
996 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
997 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
1002 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1010 input_line_pointer
= ends
+ 8;
1014 scrub_string_end
= ends
;
1016 new_length
= ends
- s
;
1017 new_buf
= (char *) xmalloc (new_length
);
1024 space
= (new_buf
+ new_length
) - new_tmp
;
1025 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1033 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1034 new_tmp
= new_buf
+ new_length
;
1040 old_buffer
= buffer
;
1041 old_input
= input_line_pointer
;
1042 old_limit
= buffer_limit
;
1044 input_line_pointer
= new_buf
;
1045 buffer_limit
= new_tmp
;
1050 HANDLE_CONDITIONAL_ASSEMBLY ();
1052 #ifdef tc_unrecognized_line
1053 if (tc_unrecognized_line (c
))
1056 input_line_pointer
--;
1057 /* Report unknown char as ignored. */
1058 ignore_rest_of_line ();
1061 #ifdef md_after_pass_hook
1062 md_after_pass_hook ();
1068 bump_line_counters ();
1071 buffer
= old_buffer
;
1072 input_line_pointer
= old_input
;
1073 buffer_limit
= old_limit
;
1085 /* Close the input file. */
1086 input_scrub_close ();
1087 #ifdef WARN_COMMENTS
1089 if (warn_comment
&& found_comment
)
1090 as_warn_where (found_comment_file
, found_comment
,
1091 "first comment found here");
1096 /* For most MRI pseudo-ops, the line actually ends at the first
1097 nonquoted space. This function looks for that point, stuffs a null
1098 in, and sets *STOPCP to the character that used to be there, and
1099 returns the location.
1101 Until I hear otherwise, I am going to assume that this is only true
1102 for the m68k MRI assembler. */
1105 mri_comment_field (stopcp
)
1112 know (flag_m68k_mri
);
1114 for (s
= input_line_pointer
;
1115 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1123 for (s
= input_line_pointer
;
1124 !is_end_of_line
[(unsigned char) *s
];
1134 /* Skip to the end of an MRI comment field. */
1137 mri_comment_end (stop
, stopc
)
1143 input_line_pointer
= stop
;
1145 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1146 ++input_line_pointer
;
1151 int ignore ATTRIBUTE_UNUSED
;
1153 as_fatal (_(".abort detected. Abandoning ship."));
1156 /* Guts of .align directive. N is the power of two to which to align.
1157 FILL may be NULL, or it may point to the bytes of the fill pattern.
1158 LEN is the length of whatever FILL points to, if anything. MAX is
1159 the maximum number of characters to skip when doing the alignment,
1160 or 0 if there is no maximum. */
1163 do_align (n
, fill
, len
, max
)
1170 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1173 /* Only make a frag if we HAVE to... */
1174 if (n
!= 0 && !need_pass_2
)
1178 if (subseg_text_p (now_seg
))
1179 frag_align_code (n
, max
);
1181 frag_align (n
, 0, max
);
1184 frag_align (n
, *fill
, max
);
1186 frag_align_pattern (n
, fill
, len
, max
);
1190 just_record_alignment
:
1193 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1196 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1197 (in bytes). A negative ARG is the negative of the length of the
1198 fill pattern. BYTES_P is non-zero if the alignment value should be
1199 interpreted as the byte boundary, rather than the power of 2. */
1202 s_align (arg
, bytes_p
)
1206 register unsigned int align
;
1214 stop
= mri_comment_field (&stopc
);
1216 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1221 align
= arg
; /* Default value from pseudo-op table. */
1225 align
= get_absolute_expression ();
1231 /* Convert to a power of 2. */
1236 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1239 as_bad (_("alignment not a power of 2"));
1248 as_warn (_("alignment too large: %u assumed"), align
);
1251 if (*input_line_pointer
!= ',')
1258 ++input_line_pointer
;
1259 if (*input_line_pointer
== ',')
1263 fill
= get_absolute_expression ();
1268 if (*input_line_pointer
!= ',')
1272 ++input_line_pointer
;
1273 max
= get_absolute_expression ();
1280 as_warn (_("expected fill pattern missing"));
1281 do_align (align
, (char *) NULL
, 0, max
);
1296 do_align (align
, &fill_char
, fill_len
, max
);
1302 if ((size_t) fill_len
> sizeof ab
)
1304 md_number_to_chars (ab
, fill
, fill_len
);
1305 do_align (align
, ab
, fill_len
, max
);
1309 demand_empty_rest_of_line ();
1312 mri_comment_end (stop
, stopc
);
1315 /* Handle the .align pseudo-op on machines where ".align 4" means
1316 align to a 4 byte boundary. */
1325 /* Handle the .align pseudo-op on machines where ".align 4" means align
1326 to a 2**4 boundary. */
1337 int ignore ATTRIBUTE_UNUSED
;
1339 register char *name
;
1343 register symbolS
*symbolP
;
1348 stop
= mri_comment_field (&stopc
);
1350 name
= input_line_pointer
;
1351 c
= get_symbol_end ();
1352 /* Just after name is now '\0'. */
1353 p
= input_line_pointer
;
1358 as_bad (_("expected symbol name"));
1359 discard_rest_of_line ();
1365 if (*input_line_pointer
!= ',')
1368 as_bad (_("expected comma after \"%s\""), name
);
1370 ignore_rest_of_line ();
1372 mri_comment_end (stop
, stopc
);
1376 input_line_pointer
++; /* skip ',' */
1378 if ((temp
= get_absolute_expression ()) < 0)
1380 as_warn (_(".COMMon length (%ld) < 0 ignored"), (long) temp
);
1381 ignore_rest_of_line ();
1383 mri_comment_end (stop
, stopc
);
1388 symbolP
= symbol_find_or_make (name
);
1391 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1393 as_bad (_("symbol `%s' is already defined"),
1394 S_GET_NAME (symbolP
));
1395 ignore_rest_of_line ();
1397 mri_comment_end (stop
, stopc
);
1401 if (S_GET_VALUE (symbolP
))
1403 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1404 as_bad (_("length of .comm \"%s\" is already %ld; not changing to %ld"),
1405 S_GET_NAME (symbolP
),
1406 (long) S_GET_VALUE (symbolP
),
1411 S_SET_VALUE (symbolP
, (valueT
) temp
);
1412 S_SET_EXTERNAL (symbolP
);
1416 extern int flag_one
;
1417 if (!temp
|| !flag_one
)
1418 S_GET_OTHER(symbolP
) = const_flag
;
1420 #endif /* not OBJ_VMS */
1421 know (symbolP
->sy_frag
== &zero_address_frag
);
1423 demand_empty_rest_of_line ();
1426 mri_comment_end (stop
, stopc
);
1429 /* The MRI COMMON pseudo-op. We handle this by creating a common
1430 symbol with the appropriate name. We make s_space do the right
1431 thing by increasing the size. */
1434 s_mri_common (small
)
1435 int small ATTRIBUTE_UNUSED
;
1451 stop
= mri_comment_field (&stopc
);
1455 name
= input_line_pointer
;
1456 if (!isdigit ((unsigned char) *name
))
1457 c
= get_symbol_end ();
1462 ++input_line_pointer
;
1464 while (isdigit ((unsigned char) *input_line_pointer
));
1466 c
= *input_line_pointer
;
1467 *input_line_pointer
= '\0';
1469 if (line_label
!= NULL
)
1471 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1472 + (input_line_pointer
- name
)
1474 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1479 sym
= symbol_find_or_make (name
);
1480 *input_line_pointer
= c
;
1484 if (*input_line_pointer
!= ',')
1488 ++input_line_pointer
;
1489 align
= get_absolute_expression ();
1492 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1494 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1495 ignore_rest_of_line ();
1496 mri_comment_end (stop
, stopc
);
1500 S_SET_EXTERNAL (sym
);
1501 mri_common_symbol
= sym
;
1505 S_SET_ALIGN (sym
, align
);
1508 if (line_label
!= NULL
)
1511 exp
.X_op
= O_symbol
;
1512 exp
.X_add_symbol
= sym
;
1513 exp
.X_add_number
= 0;
1514 symbol_set_value_expression (line_label
, &exp
);
1515 symbol_set_frag (line_label
, &zero_address_frag
);
1516 S_SET_SEGMENT (line_label
, expr_section
);
1519 /* FIXME: We just ignore the small argument, which distinguishes
1520 COMMON and COMMON.S. I don't know what we can do about it. */
1522 /* Ignore the type and hptype. */
1523 if (*input_line_pointer
== ',')
1524 input_line_pointer
+= 2;
1525 if (*input_line_pointer
== ',')
1526 input_line_pointer
+= 2;
1528 demand_empty_rest_of_line ();
1530 mri_comment_end (stop
, stopc
);
1535 int ignore ATTRIBUTE_UNUSED
;
1540 temp
= get_absolute_expression ();
1541 if (flag_readonly_data_in_text
)
1543 section
= text_section
;
1547 section
= data_section
;
1549 subseg_set (section
, (subsegT
) temp
);
1554 demand_empty_rest_of_line ();
1557 /* Handle the .appfile pseudo-op. This is automatically generated by
1558 do_scrub_chars when a preprocessor # line comment is seen with a
1559 file name. This default definition may be overridden by the object
1560 or CPU specific pseudo-ops. This function is also the default
1561 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1565 s_app_file (appfile
)
1571 /* Some assemblers tolerate immediately following '"'. */
1572 if ((s
= demand_copy_string (&length
)) != 0)
1574 /* If this is a fake .appfile, a fake newline was inserted into
1575 the buffer. Passing -2 to new_logical_line tells it to
1578 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1580 /* In MRI mode, the preprocessor may have inserted an extraneous
1583 && *input_line_pointer
== '\''
1584 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1585 ++input_line_pointer
;
1587 demand_empty_rest_of_line ();
1592 listing_source_file (s
);
1594 register_dependency (s
);
1602 /* Handle the .appline pseudo-op. This is automatically generated by
1603 do_scrub_chars when a preprocessor # line comment is seen. This
1604 default definition may be overridden by the object or CPU specific
1609 int ignore ATTRIBUTE_UNUSED
;
1613 /* The given number is that of the next line. */
1614 l
= get_absolute_expression () - 1;
1616 /* Some of the back ends can't deal with non-positive line numbers.
1617 Besides, it's silly. */
1618 as_warn (_("line numbers must be positive; line number %d rejected"),
1622 new_logical_line ((char *) NULL
, l
);
1625 listing_source_line (l
);
1628 demand_empty_rest_of_line ();
1631 /* Handle the .end pseudo-op. Actually, the real work is done in
1632 read_a_source_file. */
1636 int ignore ATTRIBUTE_UNUSED
;
1640 /* The MRI assembler permits the start symbol to follow .end,
1641 but we don't support that. */
1643 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1644 && *input_line_pointer
!= '*'
1645 && *input_line_pointer
!= '!')
1646 as_warn (_("start address not supported"));
1650 /* Handle the .err pseudo-op. */
1654 int ignore ATTRIBUTE_UNUSED
;
1656 as_bad (_(".err encountered"));
1657 demand_empty_rest_of_line ();
1660 /* Handle the MRI fail pseudo-op. */
1664 int ignore ATTRIBUTE_UNUSED
;
1671 stop
= mri_comment_field (&stopc
);
1673 temp
= get_absolute_expression ();
1675 as_warn (_(".fail %ld encountered"), (long) temp
);
1677 as_bad (_(".fail %ld encountered"), (long) temp
);
1679 demand_empty_rest_of_line ();
1682 mri_comment_end (stop
, stopc
);
1687 int ignore ATTRIBUTE_UNUSED
;
1689 expressionS rep_exp
;
1691 register long fill
= 0;
1694 #ifdef md_flush_pending_output
1695 md_flush_pending_output ();
1698 get_known_segmented_expression (&rep_exp
);
1699 if (*input_line_pointer
== ',')
1701 input_line_pointer
++;
1702 size
= get_absolute_expression ();
1703 if (*input_line_pointer
== ',')
1705 input_line_pointer
++;
1706 fill
= get_absolute_expression ();
1710 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1711 #define BSD_FILL_SIZE_CROCK_8 (8)
1712 if (size
> BSD_FILL_SIZE_CROCK_8
)
1714 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
1715 size
= BSD_FILL_SIZE_CROCK_8
;
1719 as_warn (_("size negative; .fill ignored"));
1722 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1724 if (rep_exp
.X_add_number
< 0)
1725 as_warn (_("repeat < 0; .fill ignored"));
1729 if (size
&& !need_pass_2
)
1731 if (rep_exp
.X_op
== O_constant
)
1733 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1734 (relax_substateT
) 0, (symbolS
*) 0,
1735 (offsetT
) rep_exp
.X_add_number
,
1740 /* We don't have a constant repeat count, so we can't use
1741 rs_fill. We can get the same results out of rs_space,
1742 but its argument is in bytes, so we must multiply the
1743 repeat count by size. */
1746 rep_sym
= make_expr_symbol (&rep_exp
);
1749 expressionS size_exp
;
1750 size_exp
.X_op
= O_constant
;
1751 size_exp
.X_add_number
= size
;
1753 rep_exp
.X_op
= O_multiply
;
1754 rep_exp
.X_add_symbol
= rep_sym
;
1755 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1756 rep_exp
.X_add_number
= 0;
1757 rep_sym
= make_expr_symbol (&rep_exp
);
1760 p
= frag_var (rs_space
, (int) size
, (int) size
,
1761 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1764 memset (p
, 0, (unsigned int) size
);
1766 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1767 flavoured AS. The following bizarre behaviour is to be
1768 compatible with above. I guess they tried to take up to 8
1769 bytes from a 4-byte expression and they forgot to sign
1771 #define BSD_FILL_SIZE_CROCK_4 (4)
1772 md_number_to_chars (p
, (valueT
) fill
,
1773 (size
> BSD_FILL_SIZE_CROCK_4
1774 ? BSD_FILL_SIZE_CROCK_4
1776 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1777 but emits no error message because it seems a legal thing to do.
1778 It is a degenerate case of .fill but could be emitted by a
1781 demand_empty_rest_of_line ();
1786 int ignore ATTRIBUTE_UNUSED
;
1795 stop
= mri_comment_field (&stopc
);
1799 name
= input_line_pointer
;
1800 c
= get_symbol_end ();
1801 symbolP
= symbol_find_or_make (name
);
1802 S_SET_EXTERNAL (symbolP
);
1804 *input_line_pointer
= c
;
1806 c
= *input_line_pointer
;
1809 input_line_pointer
++;
1811 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1817 demand_empty_rest_of_line ();
1820 mri_comment_end (stop
, stopc
);
1823 /* Handle the MRI IRP and IRPC pseudo-ops. */
1835 as_where (&file
, &line
);
1838 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1839 sb_add_char (&s
, *input_line_pointer
++);
1843 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1845 as_bad_where (file
, line
, "%s", err
);
1849 input_scrub_include_sb (&out
, input_line_pointer
, 1);
1851 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1854 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1855 the section to only be linked once. However, this is not supported
1856 by most object file formats. This takes an optional argument,
1857 which is what to do about duplicates. */
1861 int ignore ATTRIBUTE_UNUSED
;
1863 enum linkonce_type type
;
1867 type
= LINKONCE_DISCARD
;
1869 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1874 s
= input_line_pointer
;
1875 c
= get_symbol_end ();
1876 if (strcasecmp (s
, "discard") == 0)
1877 type
= LINKONCE_DISCARD
;
1878 else if (strcasecmp (s
, "one_only") == 0)
1879 type
= LINKONCE_ONE_ONLY
;
1880 else if (strcasecmp (s
, "same_size") == 0)
1881 type
= LINKONCE_SAME_SIZE
;
1882 else if (strcasecmp (s
, "same_contents") == 0)
1883 type
= LINKONCE_SAME_CONTENTS
;
1885 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1887 *input_line_pointer
= c
;
1890 #ifdef obj_handle_link_once
1891 obj_handle_link_once (type
);
1892 #else /* ! defined (obj_handle_link_once) */
1893 #ifdef BFD_ASSEMBLER
1897 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1898 as_warn (_(".linkonce is not supported for this object file format"));
1900 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1901 flags
|= SEC_LINK_ONCE
;
1906 case LINKONCE_DISCARD
:
1907 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1909 case LINKONCE_ONE_ONLY
:
1910 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1912 case LINKONCE_SAME_SIZE
:
1913 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1915 case LINKONCE_SAME_CONTENTS
:
1916 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1919 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1920 as_bad (_("bfd_set_section_flags: %s"),
1921 bfd_errmsg (bfd_get_error ()));
1923 #else /* ! defined (BFD_ASSEMBLER) */
1924 as_warn (_(".linkonce is not supported for this object file format"));
1925 #endif /* ! defined (BFD_ASSEMBLER) */
1926 #endif /* ! defined (obj_handle_link_once) */
1928 demand_empty_rest_of_line ();
1932 s_lcomm_internal (needs_align
, bytes_p
)
1933 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1934 (alignment); 0 if it was an ".lcomm" (2 args only). */
1936 /* 1 if the alignment value should be interpreted as the byte boundary,
1937 rather than the power of 2. */
1940 register char *name
;
1944 register symbolS
*symbolP
;
1945 segT current_seg
= now_seg
;
1946 subsegT current_subseg
= now_subseg
;
1947 const int max_alignment
= 15;
1949 segT bss_seg
= bss_section
;
1951 name
= input_line_pointer
;
1952 c
= get_symbol_end ();
1953 p
= input_line_pointer
;
1958 as_bad (_("expected symbol name"));
1959 discard_rest_of_line ();
1965 /* Accept an optional comma after the name. The comma used to be
1966 required, but Irix 5 cc does not generate it. */
1967 if (*input_line_pointer
== ',')
1969 ++input_line_pointer
;
1973 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1975 as_bad (_("missing size expression"));
1979 if ((temp
= get_absolute_expression ()) < 0)
1981 as_warn (_("BSS length (%d) < 0 ignored"), temp
);
1982 ignore_rest_of_line ();
1986 #if defined (TC_MIPS) || defined (TC_ALPHA)
1987 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1988 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1990 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1991 if ((unsigned) temp
<= bfd_get_gp_size (stdoutput
))
1993 bss_seg
= subseg_new (".sbss", 1);
1994 seg_info (bss_seg
)->bss
= 1;
1995 #ifdef BFD_ASSEMBLER
1996 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1997 as_warn (_("error setting flags for \".sbss\": %s"),
1998 bfd_errmsg (bfd_get_error ()));
2006 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
2008 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
2010 record_alignment (bss_seg
, align
);
2018 if (*input_line_pointer
!= ',')
2020 as_bad (_("expected comma after size"));
2021 ignore_rest_of_line ();
2025 input_line_pointer
++;
2028 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2030 as_bad (_("missing alignment"));
2034 align
= get_absolute_expression ();
2038 /* Convert to a power of 2. */
2043 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2046 as_bad (_("alignment not a power of 2"));
2051 if (align
> max_alignment
)
2053 align
= max_alignment
;
2054 as_warn (_("alignment too large; %d assumed"), align
);
2059 as_warn (_("alignment negative; 0 assumed"));
2062 record_alignment (bss_seg
, align
);
2066 /* Assume some objects may require alignment on some systems. */
2067 #if defined (TC_ALPHA) && ! defined (VMS)
2070 align
= ffs (temp
) - 1;
2071 if (temp
% (1 << align
))
2078 symbolP
= symbol_find_or_make (name
);
2082 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2083 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2084 #ifdef BFD_ASSEMBLER
2085 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2086 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2088 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2091 (S_GET_SEGMENT (symbolP
) == bss_seg
2092 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2096 subseg_set (bss_seg
, 1);
2099 frag_align (align
, 0, 0);
2101 /* Detach from old frag. */
2102 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2103 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2105 symbol_set_frag (symbolP
, frag_now
);
2106 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2107 (offsetT
) temp
, (char *) 0);
2110 S_SET_SEGMENT (symbolP
, bss_seg
);
2113 /* The symbol may already have been created with a preceding
2114 ".globl" directive -- be careful not to step on storage class
2115 in that case. Otherwise, set it to static. */
2116 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2118 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2120 #endif /* OBJ_COFF */
2123 S_SET_SIZE (symbolP
, temp
);
2127 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2129 subseg_set (current_seg
, current_subseg
);
2131 demand_empty_rest_of_line ();
2135 s_lcomm (needs_align
)
2138 s_lcomm_internal (needs_align
, 0);
2142 s_lcomm_bytes (needs_align
)
2145 s_lcomm_internal (needs_align
, 1);
2150 int ignore ATTRIBUTE_UNUSED
;
2152 register char *name
;
2156 register symbolS
*symbolP
;
2158 /* We permit ANY defined expression: BSD4.2 demands constants. */
2159 name
= input_line_pointer
;
2160 c
= get_symbol_end ();
2161 p
= input_line_pointer
;
2166 as_bad (_("expected symbol name"));
2167 discard_rest_of_line ();
2173 if (*input_line_pointer
!= ',')
2176 as_bad (_("expected comma after \"%s\""), name
);
2178 ignore_rest_of_line ();
2182 input_line_pointer
++;
2185 if (exp
.X_op
!= O_constant
2186 && exp
.X_op
!= O_register
)
2188 as_bad (_("bad expression"));
2189 ignore_rest_of_line ();
2194 symbolP
= symbol_find_or_make (name
);
2196 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2197 symbolP->sy_desc == 0) out of this test because coff doesn't have
2198 those fields, and I can't see when they'd ever be tripped. I
2199 don't think I understand why they were here so I may have
2200 introduced a bug. As recently as 1.37 didn't have this test
2201 anyway. xoxorich. */
2203 if (S_GET_SEGMENT (symbolP
) == undefined_section
2204 && S_GET_VALUE (symbolP
) == 0)
2206 /* The name might be an undefined .global symbol; be sure to
2207 keep the "external" bit. */
2208 S_SET_SEGMENT (symbolP
,
2209 (exp
.X_op
== O_constant
2212 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2216 as_bad (_("symbol `%s' is already defined"), name
);
2220 demand_empty_rest_of_line ();
2223 /* Read a line into an sb. */
2229 char quote1
, quote2
, inquote
;
2231 if (input_line_pointer
[-1] == '\n')
2232 bump_line_counters ();
2234 if (input_line_pointer
>= buffer_limit
)
2236 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2237 if (buffer_limit
== 0)
2241 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2242 code needs to be changed. */
2251 #ifdef LEX_IS_STRINGQUOTE
2257 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2258 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2260 if (inquote
== *input_line_pointer
)
2262 else if (inquote
== '\0')
2264 if (*input_line_pointer
== quote1
)
2266 else if (*input_line_pointer
== quote2
)
2270 sb_add_char (line
, *input_line_pointer
++);
2273 while (input_line_pointer
< buffer_limit
2274 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2276 if (input_line_pointer
[-1] == '\n')
2277 bump_line_counters ();
2278 ++input_line_pointer
;
2284 /* Define a macro. This is an interface to macro.c, which is shared
2285 between gas and gasp. */
2289 int ignore ATTRIBUTE_UNUSED
;
2298 as_where (&file
, &line
);
2301 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2302 sb_add_char (&s
, *input_line_pointer
++);
2305 if (line_label
!= NULL
)
2306 sb_add_string (&label
, S_GET_NAME (line_label
));
2308 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2310 as_bad_where (file
, line
, "%s", err
);
2313 if (line_label
!= NULL
)
2315 S_SET_SEGMENT (line_label
, undefined_section
);
2316 S_SET_VALUE (line_label
, 0);
2317 symbol_set_frag (line_label
, &zero_address_frag
);
2320 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2321 && hash_find (po_hash
, name
) != NULL
)
2324 && hash_find (po_hash
, name
+ 1) != NULL
))
2325 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2332 /* Handle the .mexit pseudo-op, which immediately exits a macro
2337 int ignore ATTRIBUTE_UNUSED
;
2339 cond_exit_macro (macro_nest
);
2340 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2343 /* Switch in and out of MRI mode. */
2347 int ignore ATTRIBUTE_UNUSED
;
2351 on
= get_absolute_expression ();
2352 old_flag
= flag_mri
;
2370 /* Operator precedence changes in m68k MRI mode, so we need to
2371 update the operator rankings. */
2372 expr_set_precedence ();
2374 #ifdef MRI_MODE_CHANGE
2376 MRI_MODE_CHANGE (on
);
2379 demand_empty_rest_of_line ();
2382 /* Handle changing the location counter. */
2385 do_org (segment
, exp
, fill
)
2390 if (segment
!= now_seg
&& segment
!= absolute_section
)
2391 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2393 if (now_seg
== absolute_section
)
2396 as_warn (_("ignoring fill value in absolute section"));
2397 if (exp
->X_op
!= O_constant
)
2399 as_bad (_("only constant offsets supported in absolute section"));
2400 exp
->X_add_number
= 0;
2402 abs_section_offset
= exp
->X_add_number
;
2407 symbolS
*sym
= exp
->X_add_symbol
;
2408 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2410 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2412 /* Handle complex expressions. */
2413 sym
= make_expr_symbol (exp
);
2417 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2424 int ignore ATTRIBUTE_UNUSED
;
2426 register segT segment
;
2428 register long temp_fill
;
2430 #ifdef md_flush_pending_output
2431 md_flush_pending_output ();
2434 /* The m68k MRI assembler has a different meaning for .org. It
2435 means to create an absolute section at a given address. We can't
2436 support that--use a linker script instead. */
2439 as_bad (_("MRI style ORG pseudo-op not supported"));
2440 ignore_rest_of_line ();
2444 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2445 thing as a sub-segment-relative origin. Any absolute origin is
2446 given a warning, then assumed to be segment-relative. Any
2447 segmented origin expression ("foo+42") had better be in the right
2448 segment or the .org is ignored.
2450 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2451 we never know sub-segment sizes when we are reading code. BSD
2452 will crash trying to emit negative numbers of filler bytes in
2453 certain .orgs. We don't crash, but see as-write for that code.
2455 Don't make frag if need_pass_2==1. */
2456 segment
= get_known_segmented_expression (&exp
);
2457 if (*input_line_pointer
== ',')
2459 input_line_pointer
++;
2460 temp_fill
= get_absolute_expression ();
2466 do_org (segment
, &exp
, temp_fill
);
2468 demand_empty_rest_of_line ();
2471 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2472 called by the obj-format routine which handles section changing
2473 when in MRI mode. It will create a new section, and return it. It
2474 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2475 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2476 flags will be set in the section. */
2480 char *type ATTRIBUTE_UNUSED
;
2490 name
= input_line_pointer
;
2491 if (!isdigit ((unsigned char) *name
))
2492 c
= get_symbol_end ();
2497 ++input_line_pointer
;
2499 while (isdigit ((unsigned char) *input_line_pointer
));
2501 c
= *input_line_pointer
;
2502 *input_line_pointer
= '\0';
2505 name
= xstrdup (name
);
2507 *input_line_pointer
= c
;
2509 seg
= subseg_new (name
, 0);
2511 if (*input_line_pointer
== ',')
2515 ++input_line_pointer
;
2516 align
= get_absolute_expression ();
2517 record_alignment (seg
, align
);
2521 if (*input_line_pointer
== ',')
2523 c
= *++input_line_pointer
;
2524 c
= toupper ((unsigned char) c
);
2525 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2528 as_bad (_("unrecognized section type"));
2529 ++input_line_pointer
;
2531 #ifdef BFD_ASSEMBLER
2535 flags
= SEC_NO_FLAGS
;
2537 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2538 else if (*type
== 'D' || *type
== 'M')
2539 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2540 else if (*type
== 'R')
2541 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2542 if (flags
!= SEC_NO_FLAGS
)
2544 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2545 as_warn (_("error setting flags for \"%s\": %s"),
2546 bfd_section_name (stdoutput
, seg
),
2547 bfd_errmsg (bfd_get_error ()));
2553 /* Ignore the HP type. */
2554 if (*input_line_pointer
== ',')
2555 input_line_pointer
+= 2;
2557 demand_empty_rest_of_line ();
2559 #else /* ! TC_M68K */
2568 name
= input_line_pointer
;
2569 c
= get_symbol_end ();
2571 name
= xstrdup (name
);
2573 *input_line_pointer
= c
;
2575 seg
= subseg_new (name
, 0);
2577 if (*input_line_pointer
!= ',')
2583 ++input_line_pointer
;
2585 sectype
= input_line_pointer
;
2586 c
= get_symbol_end ();
2587 if (*sectype
== '\0')
2589 else if (strcasecmp (sectype
, "text") == 0)
2591 else if (strcasecmp (sectype
, "data") == 0)
2593 else if (strcasecmp (sectype
, "romdata") == 0)
2596 as_warn (_("unrecognized section type `%s'"), sectype
);
2597 *input_line_pointer
= c
;
2600 if (*input_line_pointer
== ',')
2604 ++input_line_pointer
;
2606 seccmd
= input_line_pointer
;
2607 c
= get_symbol_end ();
2608 if (strcasecmp (seccmd
, "absolute") == 0)
2610 as_bad (_("absolute sections are not supported"));
2611 *input_line_pointer
= c
;
2612 ignore_rest_of_line ();
2615 else if (strcasecmp (seccmd
, "align") == 0)
2619 *input_line_pointer
= c
;
2620 align
= get_absolute_expression ();
2621 record_alignment (seg
, align
);
2625 as_warn (_("unrecognized section command `%s'"), seccmd
);
2626 *input_line_pointer
= c
;
2630 demand_empty_rest_of_line ();
2632 #else /* ! TC_I960 */
2633 /* The MRI assembler seems to use different forms of .sect for
2634 different targets. */
2635 as_bad ("MRI mode not supported for this target");
2636 ignore_rest_of_line ();
2637 #endif /* ! TC_I960 */
2638 #endif /* ! TC_M68K */
2641 /* Handle the .print pseudo-op. */
2645 int ignore ATTRIBUTE_UNUSED
;
2650 s
= demand_copy_C_string (&len
);
2652 demand_empty_rest_of_line ();
2655 /* Handle the .purgem pseudo-op. */
2659 int ignore ATTRIBUTE_UNUSED
;
2661 if (is_it_end_of_statement ())
2663 demand_empty_rest_of_line ();
2673 name
= input_line_pointer
;
2674 c
= get_symbol_end ();
2675 delete_macro (name
);
2676 *input_line_pointer
= c
;
2679 while (*input_line_pointer
++ == ',');
2681 --input_line_pointer
;
2682 demand_empty_rest_of_line ();
2685 /* Handle the .rept pseudo-op. */
2689 int ignore ATTRIBUTE_UNUSED
;
2693 count
= get_absolute_expression ();
2695 do_repeat (count
, "REPT", "ENDR");
2698 /* This function provides a generic repeat block implementation. It allows
2699 different directives to be used as the start/end keys. */
2702 do_repeat (count
, start
, end
)
2711 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2713 as_bad (_("%s without %s"), start
, end
);
2719 sb_add_sb (&many
, &one
);
2723 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2725 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2728 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2729 input buffers to skip. Assumes that conditionals preceding the loop end
2730 are properly nested.
2732 This function makes it easier to implement a premature "break" out of the
2733 loop. The EXTRA arg accounts for other buffers we might have inserted,
2734 such as line substitutions. */
2740 cond_exit_macro (macro_nest
);
2741 while (extra
-- >= 0)
2742 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2745 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2746 this is .equiv, and it is an error if the symbol is already
2753 register char *name
;
2754 register char delim
;
2755 register char *end_name
;
2756 register symbolS
*symbolP
;
2758 /* Especial apologies for the random logic:
2759 this just grew, and could be parsed much more simply!
2761 name
= input_line_pointer
;
2762 delim
= get_symbol_end ();
2763 end_name
= input_line_pointer
;
2766 if (name
== end_name
)
2768 as_bad (_("expected symbol name"));
2769 discard_rest_of_line ();
2775 if (*input_line_pointer
!= ',')
2778 as_bad (_("expected comma after \"%s\""), name
);
2780 ignore_rest_of_line ();
2784 input_line_pointer
++;
2787 if (name
[0] == '.' && name
[1] == '\0')
2789 /* Turn '. = mumble' into a .org mumble. */
2790 register segT segment
;
2793 segment
= get_known_segmented_expression (&exp
);
2796 do_org (segment
, &exp
, 0);
2802 if ((symbolP
= symbol_find (name
)) == NULL
2803 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2806 /* When doing symbol listings, play games with dummy fragments living
2807 outside the normal fragment chain to record the file and line info
2809 if (listing
& LISTING_SYMBOLS
)
2811 extern struct list_info_struct
*listing_tail
;
2812 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2813 memset (dummy_frag
, 0, sizeof (fragS
));
2814 dummy_frag
->fr_type
= rs_fill
;
2815 dummy_frag
->line
= listing_tail
;
2816 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2817 dummy_frag
->fr_symbol
= symbolP
;
2821 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2824 /* "set" symbols are local unless otherwise specified. */
2825 SF_SET_LOCAL (symbolP
);
2826 #endif /* OBJ_COFF */
2829 symbol_table_insert (symbolP
);
2834 && S_IS_DEFINED (symbolP
)
2835 && S_GET_SEGMENT (symbolP
) != reg_section
)
2836 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2838 pseudo_set (symbolP
);
2839 demand_empty_rest_of_line ();
2853 #ifdef md_flush_pending_output
2854 md_flush_pending_output ();
2858 stop
= mri_comment_field (&stopc
);
2860 /* In m68k MRI mode, we need to align to a word boundary, unless
2862 if (flag_m68k_mri
&& mult
> 1)
2864 if (now_seg
== absolute_section
)
2866 abs_section_offset
+= abs_section_offset
& 1;
2867 if (line_label
!= NULL
)
2868 S_SET_VALUE (line_label
, abs_section_offset
);
2870 else if (mri_common_symbol
!= NULL
)
2874 val
= S_GET_VALUE (mri_common_symbol
);
2877 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2878 if (line_label
!= NULL
)
2880 expressionS
*symexp
;
2882 symexp
= symbol_get_value_expression (line_label
);
2883 know (symexp
->X_op
== O_symbol
);
2884 know (symexp
->X_add_symbol
== mri_common_symbol
);
2885 symexp
->X_add_number
+= 1;
2891 do_align (1, (char *) NULL
, 0, 0);
2892 if (line_label
!= NULL
)
2894 symbol_set_frag (line_label
, frag_now
);
2895 S_SET_VALUE (line_label
, frag_now_fix ());
2905 if (*input_line_pointer
== ',')
2907 ++input_line_pointer
;
2912 val
.X_op
= O_constant
;
2913 val
.X_add_number
= 0;
2916 if (val
.X_op
!= O_constant
2917 || val
.X_add_number
< - 0x80
2918 || val
.X_add_number
> 0xff
2919 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2921 if (exp
.X_op
!= O_constant
)
2922 as_bad (_("unsupported variable size or fill value"));
2929 bytes
= mult
* exp
.X_add_number
;
2930 for (i
= 0; i
< exp
.X_add_number
; i
++)
2931 emit_expr (&val
, mult
);
2936 if (exp
.X_op
== O_constant
)
2940 repeat
= exp
.X_add_number
;
2947 as_warn (_(".space repeat count is zero, ignored"));
2948 else if (repeat
< 0)
2949 as_warn (_(".space repeat count is negative, ignored"));
2953 /* If we are in the absolute section, just bump the offset. */
2954 if (now_seg
== absolute_section
)
2956 abs_section_offset
+= repeat
;
2960 /* If we are secretly in an MRI common section, then
2961 creating space just increases the size of the common
2963 if (mri_common_symbol
!= NULL
)
2965 S_SET_VALUE (mri_common_symbol
,
2966 S_GET_VALUE (mri_common_symbol
) + repeat
);
2971 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2972 (offsetT
) repeat
, (char *) 0);
2976 if (now_seg
== absolute_section
)
2978 as_bad (_("space allocation too complex in absolute section"));
2979 subseg_set (text_section
, 0);
2982 if (mri_common_symbol
!= NULL
)
2984 as_bad (_("space allocation too complex in common section"));
2985 mri_common_symbol
= NULL
;
2989 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2990 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2994 *p
= val
.X_add_number
;
2999 /* In MRI mode, after an odd number of bytes, we must align to an
3000 even word boundary, unless the next instruction is a dc.b, ds.b
3002 if (flag_mri
&& (bytes
& 1) != 0)
3003 mri_pending_align
= 1;
3005 demand_empty_rest_of_line ();
3008 mri_comment_end (stop
, stopc
);
3011 /* This is like s_space, but the value is a floating point number with
3012 the given precision. This is for the MRI dcb.s pseudo-op and
3016 s_float_space (float_type
)
3021 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3026 stop
= mri_comment_field (&stopc
);
3028 count
= get_absolute_expression ();
3031 if (*input_line_pointer
!= ',')
3033 as_bad (_("missing value"));
3034 ignore_rest_of_line ();
3036 mri_comment_end (stop
, stopc
);
3040 ++input_line_pointer
;
3044 /* Skip any 0{letter} that may be present. Don't even check if the
3045 * letter is legal. */
3046 if (input_line_pointer
[0] == '0'
3047 && isalpha ((unsigned char) input_line_pointer
[1]))
3048 input_line_pointer
+= 2;
3050 /* Accept :xxxx, where the x's are hex digits, for a floating point
3051 with the exact digits specified. */
3052 if (input_line_pointer
[0] == ':')
3054 flen
= hex_float (float_type
, temp
);
3057 ignore_rest_of_line ();
3059 mri_comment_end (stop
, stopc
);
3067 err
= md_atof (float_type
, temp
, &flen
);
3068 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3072 as_bad (_("bad floating literal: %s"), err
);
3073 ignore_rest_of_line ();
3075 mri_comment_end (stop
, stopc
);
3080 while (--count
>= 0)
3084 p
= frag_more (flen
);
3085 memcpy (p
, temp
, (unsigned int) flen
);
3088 demand_empty_rest_of_line ();
3091 mri_comment_end (stop
, stopc
);
3094 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3098 int ignore ATTRIBUTE_UNUSED
;
3104 stop
= mri_comment_field (&stopc
);
3105 abs_section_offset
= get_absolute_expression ();
3106 subseg_set (absolute_section
, 0);
3107 demand_empty_rest_of_line ();
3109 mri_comment_end (stop
, stopc
);
3114 int ignore ATTRIBUTE_UNUSED
;
3118 temp
= get_absolute_expression ();
3119 subseg_set (text_section
, (subsegT
) temp
);
3120 demand_empty_rest_of_line ();
3122 const_flag
&= ~IN_DEFAULT_SECTION
;
3127 demand_empty_rest_of_line ()
3130 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3131 input_line_pointer
++;
3133 ignore_rest_of_line ();
3135 /* Return having already swallowed end-of-line. */
3139 ignore_rest_of_line ()
3141 /* For suspect lines: gives warning. */
3142 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3144 if (isprint ((unsigned char) *input_line_pointer
))
3145 as_warn (_("rest of line ignored; first ignored character is `%c'"),
3146 *input_line_pointer
);
3148 as_warn (_("rest of line ignored; first ignored character valued 0x%x"),
3149 *input_line_pointer
);
3151 while (input_line_pointer
< buffer_limit
3152 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3153 input_line_pointer
++;
3156 input_line_pointer
++;
3158 /* Return pointing just after end-of-line. */
3159 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3163 discard_rest_of_line ()
3165 while (input_line_pointer
< buffer_limit
3166 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3167 input_line_pointer
++;
3169 input_line_pointer
++;
3171 /* Return pointing just after end-of-line. */
3172 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3175 /* In: Pointer to a symbol.
3176 Input_line_pointer->expression.
3178 Out: Input_line_pointer->just after any whitespace after expression.
3179 Tried to set symbol to value of expression.
3180 Will change symbols type, value, and frag; */
3183 pseudo_set (symbolP
)
3187 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3189 #endif /* OBJ_AOUT or OBJ_BOUT */
3191 know (symbolP
); /* NULL pointer is logic error. */
3192 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3193 ext
= S_IS_EXTERNAL (symbolP
);
3194 #endif /* OBJ_AOUT or OBJ_BOUT */
3196 (void) expression (&exp
);
3198 if (exp
.X_op
== O_illegal
)
3199 as_bad (_("illegal expression"));
3200 else if (exp
.X_op
== O_absent
)
3201 as_bad (_("missing expression"));
3202 else if (exp
.X_op
== O_big
)
3204 if (exp
.X_add_number
> 0)
3205 as_bad (_("bignum invalid"));
3207 as_bad (_("floating point number invalid"));
3209 else if (exp
.X_op
== O_subtract
3210 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3211 == S_GET_SEGMENT (exp
.X_op_symbol
))
3212 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3213 && (symbol_get_frag (exp
.X_add_symbol
)
3214 == symbol_get_frag (exp
.X_op_symbol
)))
3216 exp
.X_op
= O_constant
;
3217 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3218 - S_GET_VALUE (exp
.X_op_symbol
));
3226 exp
.X_add_number
= 0;
3229 S_SET_SEGMENT (symbolP
, absolute_section
);
3230 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3232 S_SET_EXTERNAL (symbolP
);
3234 S_CLEAR_EXTERNAL (symbolP
);
3235 #endif /* OBJ_AOUT or OBJ_BOUT */
3236 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3237 if (exp
.X_op
!= O_constant
)
3238 symbol_set_frag (symbolP
, &zero_address_frag
);
3242 S_SET_SEGMENT (symbolP
, reg_section
);
3243 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3244 symbol_set_frag (symbolP
, &zero_address_frag
);
3248 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3249 || exp
.X_add_number
!= 0)
3250 symbol_set_value_expression (symbolP
, &exp
);
3251 else if (symbol_section_p (symbolP
))
3252 as_bad ("attempt to set value of section symbol");
3255 symbolS
*s
= exp
.X_add_symbol
;
3257 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3258 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3260 S_SET_EXTERNAL (symbolP
);
3262 S_CLEAR_EXTERNAL (symbolP
);
3263 #endif /* OBJ_AOUT or OBJ_BOUT */
3264 S_SET_VALUE (symbolP
,
3265 exp
.X_add_number
+ S_GET_VALUE (s
));
3266 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3267 copy_symbol_attributes (symbolP
, s
);
3272 /* The value is some complex expression.
3273 FIXME: Should we set the segment to anything? */
3274 symbol_set_value_expression (symbolP
, &exp
);
3281 CONStruct more frag of .bytes, or .words etc.
3282 Should need_pass_2 be 1 then emit no frag(s).
3283 This understands EXPRESSIONS.
3287 This has a split personality. We use expression() to read the
3288 value. We can detect if the value won't fit in a byte or word.
3289 But we can't detect if expression() discarded significant digits
3290 in the case of a long. Not worth the crocks required to fix it. */
3292 /* Select a parser for cons expressions. */
3294 /* Some targets need to parse the expression in various fancy ways.
3295 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3296 (for example, the HPPA does this). Otherwise, you can define
3297 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3298 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3299 are defined, which is the normal case, then only simple expressions
3304 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3307 #ifndef TC_PARSE_CONS_EXPRESSION
3308 #ifdef BITFIELD_CONS_EXPRESSIONS
3309 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3311 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3313 #ifdef REPEAT_CONS_EXPRESSIONS
3314 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3316 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3319 /* If we haven't gotten one yet, just call expression. */
3320 #ifndef TC_PARSE_CONS_EXPRESSION
3321 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3325 /* Worker to do .byte etc statements.
3326 Clobbers input_line_pointer and checks end-of-line. */
3329 cons_worker (nbytes
, rva
)
3330 register int nbytes
; /* 1=.byte, 2=.word, 4=.long. */
3338 #ifdef md_flush_pending_output
3339 md_flush_pending_output ();
3343 stop
= mri_comment_field (&stopc
);
3345 if (is_it_end_of_statement ())
3347 demand_empty_rest_of_line ();
3349 mri_comment_end (stop
, stopc
);
3353 #ifdef md_cons_align
3354 md_cons_align (nbytes
);
3362 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3365 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3369 if (exp
.X_op
== O_symbol
)
3370 exp
.X_op
= O_symbol_rva
;
3372 as_fatal (_("rva without symbol"));
3374 emit_expr (&exp
, (unsigned int) nbytes
);
3377 while (*input_line_pointer
++ == ',');
3379 /* In MRI mode, after an odd number of bytes, we must align to an
3380 even word boundary, unless the next instruction is a dc.b, ds.b
3382 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3383 mri_pending_align
= 1;
3385 input_line_pointer
--; /* Put terminator back into stream. */
3387 demand_empty_rest_of_line ();
3390 mri_comment_end (stop
, stopc
);
3397 cons_worker (size
, 0);
3404 cons_worker (size
, 1);
3407 /* Put the contents of expression EXP into the object file using
3408 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3411 emit_expr (exp
, nbytes
)
3413 unsigned int nbytes
;
3417 valueT extra_digit
= 0;
3419 /* Don't do anything if we are going to make another pass. */
3425 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3426 appear as a four byte positive constant in the .line section,
3427 followed by a 2 byte 0xffff. Look for that case here. */
3429 static int dwarf_line
= -1;
3431 if (strcmp (segment_name (now_seg
), ".line") != 0)
3433 else if (dwarf_line
>= 0
3435 && exp
->X_op
== O_constant
3436 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3437 listing_source_line ((unsigned int) dwarf_line
);
3438 else if (nbytes
== 4
3439 && exp
->X_op
== O_constant
3440 && exp
->X_add_number
>= 0)
3441 dwarf_line
= exp
->X_add_number
;
3446 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3447 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3448 AT_sibling (0x12) followed by a four byte address of the sibling
3449 followed by a 2 byte AT_name (0x38) followed by the name of the
3450 file. We look for that case here. */
3452 static int dwarf_file
= 0;
3454 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3456 else if (dwarf_file
== 0
3458 && exp
->X_op
== O_constant
3459 && exp
->X_add_number
== 0x11)
3461 else if (dwarf_file
== 1
3463 && exp
->X_op
== O_constant
3464 && exp
->X_add_number
== 0x12)
3466 else if (dwarf_file
== 2
3469 else if (dwarf_file
== 3
3471 && exp
->X_op
== O_constant
3472 && exp
->X_add_number
== 0x38)
3477 /* The variable dwarf_file_string tells stringer that the string
3478 may be the name of the source file. */
3479 if (dwarf_file
== 4)
3480 dwarf_file_string
= 1;
3482 dwarf_file_string
= 0;
3487 if (check_eh_frame (exp
, &nbytes
))
3492 /* Allow `.word 0' in the absolute section. */
3493 if (now_seg
== absolute_section
)
3495 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3496 as_bad (_("attempt to store value in absolute section"));
3497 abs_section_offset
+= nbytes
;
3501 /* Handle a negative bignum. */
3503 && exp
->X_add_number
== 0
3504 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3505 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3508 unsigned long carry
;
3510 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3512 /* Negate the bignum: one's complement each digit and add 1. */
3514 for (i
= 0; i
< exp
->X_add_number
; i
++)
3518 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3521 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3522 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3525 /* We can ignore any carry out, because it will be handled by
3526 extra_digit if it is needed. */
3528 extra_digit
= (valueT
) -1;
3532 if (op
== O_absent
|| op
== O_illegal
)
3534 as_warn (_("zero assumed for missing expression"));
3535 exp
->X_add_number
= 0;
3538 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3540 as_bad (_("floating point number invalid"));
3541 exp
->X_add_number
= 0;
3544 else if (op
== O_register
)
3546 as_warn (_("register value used as expression"));
3550 p
= frag_more ((int) nbytes
);
3552 #ifndef WORKING_DOT_WORD
3553 /* If we have the difference of two symbols in a word, save it on
3554 the broken_words list. See the code in write.c. */
3555 if (op
== O_subtract
&& nbytes
== 2)
3557 struct broken_word
*x
;
3559 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3560 x
->next_broken_word
= broken_words
;
3563 x
->subseg
= now_subseg
;
3565 x
->word_goes_here
= p
;
3567 x
->add
= exp
->X_add_symbol
;
3568 x
->sub
= exp
->X_op_symbol
;
3569 x
->addnum
= exp
->X_add_number
;
3576 /* If we have an integer, but the number of bytes is too large to
3577 pass to md_number_to_chars, handle it as a bignum. */
3578 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3583 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3584 extra_digit
= (valueT
) -1;
3585 val
= (valueT
) exp
->X_add_number
;
3589 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3590 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3594 op
= exp
->X_op
= O_big
;
3595 exp
->X_add_number
= gencnt
;
3598 if (op
== O_constant
)
3600 register valueT get
;
3601 register valueT use
;
3602 register valueT mask
;
3604 register valueT unmask
;
3606 /* JF << of >= number of bits in the object is undefined. In
3607 particular SPARC (Sun 4) has problems. */
3608 if (nbytes
>= sizeof (valueT
))
3611 if (nbytes
> sizeof (valueT
))
3614 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3618 /* Don't store these bits. */
3619 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3620 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3623 unmask
= ~mask
; /* Do store these bits. */
3626 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3627 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3630 get
= exp
->X_add_number
;
3632 if ((get
& mask
) != 0
3633 && ((get
& mask
) != mask
3634 || (get
& hibit
) == 0))
3635 { /* Leading bits contain both 0s & 1s. */
3636 as_warn (_("value 0x%lx truncated to 0x%lx"),
3637 (unsigned long) get
, (unsigned long) use
);
3639 /* Put bytes in right order. */
3640 md_number_to_chars (p
, use
, (int) nbytes
);
3642 else if (op
== O_big
)
3645 LITTLENUM_TYPE
*nums
;
3647 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3649 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3652 as_warn (_("bignum truncated to %d bytes"), nbytes
);
3656 if (target_big_endian
)
3658 while (nbytes
> size
)
3660 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3661 nbytes
-= CHARS_PER_LITTLENUM
;
3662 p
+= CHARS_PER_LITTLENUM
;
3665 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3669 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3670 size
-= CHARS_PER_LITTLENUM
;
3671 p
+= CHARS_PER_LITTLENUM
;
3676 nums
= generic_bignum
;
3679 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3681 size
-= CHARS_PER_LITTLENUM
;
3682 p
+= CHARS_PER_LITTLENUM
;
3683 nbytes
-= CHARS_PER_LITTLENUM
;
3688 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3689 nbytes
-= CHARS_PER_LITTLENUM
;
3690 p
+= CHARS_PER_LITTLENUM
;
3696 memset (p
, 0, nbytes
);
3698 /* Now we need to generate a fixS to record the symbol value.
3699 This is easy for BFD. For other targets it can be more
3700 complex. For very complex cases (currently, the HPPA and
3701 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3702 want. For simpler cases, you can define TC_CONS_RELOC to be
3703 the name of the reloc code that should be stored in the fixS.
3704 If neither is defined, the code uses NO_RELOC if it is
3705 defined, and otherwise uses 0. */
3707 #ifdef BFD_ASSEMBLER
3708 #ifdef TC_CONS_FIX_NEW
3709 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3712 bfd_reloc_code_real_type r
;
3729 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3733 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3738 #ifdef TC_CONS_FIX_NEW
3739 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3741 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3742 it is defined, otherwise use NO_RELOC if it is defined,
3744 #ifndef TC_CONS_RELOC
3746 #define TC_CONS_RELOC NO_RELOC
3748 #define TC_CONS_RELOC 0
3751 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3753 #endif /* TC_CONS_FIX_NEW */
3754 #endif /* BFD_ASSEMBLER */
3758 #ifdef BITFIELD_CONS_EXPRESSIONS
3760 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3761 w:x,y:z, where w and y are bitwidths and x and y are values. They
3762 then pack them all together. We do a little better in that we allow
3763 them in words, longs, etc. and we'll pack them in target byte order
3766 The rules are: pack least significat bit first, if a field doesn't
3767 entirely fit, put it in the next unit. Overflowing the bitfield is
3768 explicitly *not* even a warning. The bitwidth should be considered
3771 To use this function the tc-XXX.h file should define
3772 BITFIELD_CONS_EXPRESSIONS. */
3775 parse_bitfield_cons (exp
, nbytes
)
3777 unsigned int nbytes
;
3779 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3780 char *hold
= input_line_pointer
;
3782 (void) expression (exp
);
3784 if (*input_line_pointer
== ':')
3791 unsigned long width
;
3793 if (*input_line_pointer
!= ':')
3795 input_line_pointer
= hold
;
3797 } /* Next piece is not a bitfield. */
3799 /* In the general case, we can't allow
3800 full expressions with symbol
3801 differences and such. The relocation
3802 entries for symbols not defined in this
3803 assembly would require arbitrary field
3804 widths, positions, and masks which most
3805 of our current object formats don't
3808 In the specific case where a symbol
3809 *is* defined in this assembly, we
3810 *could* build fixups and track it, but
3811 this could lead to confusion for the
3812 backends. I'm lazy. I'll take any
3813 SEG_ABSOLUTE. I think that means that
3814 you can use a previous .set or
3815 .equ type symbol. xoxorich. */
3817 if (exp
->X_op
== O_absent
)
3819 as_warn (_("using a bit field width of zero"));
3820 exp
->X_add_number
= 0;
3821 exp
->X_op
= O_constant
;
3822 } /* Implied zero width bitfield. */
3824 if (exp
->X_op
!= O_constant
)
3826 *input_line_pointer
= '\0';
3827 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3828 *input_line_pointer
= ':';
3829 demand_empty_rest_of_line ();
3831 } /* Too complex. */
3833 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3835 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3836 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3837 width
= BITS_PER_CHAR
* nbytes
;
3840 if (width
> bits_available
)
3842 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3843 input_line_pointer
= hold
;
3844 exp
->X_add_number
= value
;
3849 hold
= ++input_line_pointer
;
3851 (void) expression (exp
);
3852 if (exp
->X_op
!= O_constant
)
3854 char cache
= *input_line_pointer
;
3856 *input_line_pointer
= '\0';
3857 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3858 *input_line_pointer
= cache
;
3859 demand_empty_rest_of_line ();
3861 } /* Too complex. */
3863 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3864 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3866 if ((bits_available
-= width
) == 0
3867 || is_it_end_of_statement ()
3868 || *input_line_pointer
!= ',')
3871 } /* All the bitfields we're gonna get. */
3873 hold
= ++input_line_pointer
;
3874 (void) expression (exp
);
3877 exp
->X_add_number
= value
;
3878 exp
->X_op
= O_constant
;
3879 exp
->X_unsigned
= 1;
3883 #endif /* BITFIELD_CONS_EXPRESSIONS */
3885 /* Handle an MRI style string expression. */
3889 parse_mri_cons (exp
, nbytes
)
3891 unsigned int nbytes
;
3893 if (*input_line_pointer
!= '\''
3894 && (input_line_pointer
[1] != '\''
3895 || (*input_line_pointer
!= 'A'
3896 && *input_line_pointer
!= 'E')))
3897 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3901 unsigned int result
= 0;
3903 /* An MRI style string. Cut into as many bytes as will fit into
3904 a nbyte chunk, left justify if necessary, and separate with
3905 commas so we can try again later. */
3906 if (*input_line_pointer
== 'A')
3907 ++input_line_pointer
;
3908 else if (*input_line_pointer
== 'E')
3910 as_bad (_("EBCDIC constants are not supported"));
3911 ++input_line_pointer
;
3914 input_line_pointer
++;
3915 for (scan
= 0; scan
< nbytes
; scan
++)
3917 if (*input_line_pointer
== '\'')
3919 if (input_line_pointer
[1] == '\'')
3921 input_line_pointer
++;
3926 result
= (result
<< 8) | (*input_line_pointer
++);
3930 while (scan
< nbytes
)
3936 /* Create correct expression. */
3937 exp
->X_op
= O_constant
;
3938 exp
->X_add_number
= result
;
3940 /* Fake it so that we can read the next char too. */
3941 if (input_line_pointer
[0] != '\'' ||
3942 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3944 input_line_pointer
-= 2;
3945 input_line_pointer
[0] = ',';
3946 input_line_pointer
[1] = '\'';
3949 input_line_pointer
++;
3952 #endif /* TC_M68K */
3954 #ifdef REPEAT_CONS_EXPRESSIONS
3956 /* Parse a repeat expression for cons. This is used by the MIPS
3957 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3958 object file COUNT times.
3960 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3963 parse_repeat_cons (exp
, nbytes
)
3965 unsigned int nbytes
;
3972 if (*input_line_pointer
!= ':')
3974 /* No repeat count. */
3978 ++input_line_pointer
;
3979 expression (&count
);
3980 if (count
.X_op
!= O_constant
3981 || count
.X_add_number
<= 0)
3983 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
3987 /* The cons function is going to output this expression once. So we
3988 output it count - 1 times. */
3989 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3990 emit_expr (exp
, nbytes
);
3993 #endif /* REPEAT_CONS_EXPRESSIONS */
3995 /* Parse a floating point number represented as a hex constant. This
3996 permits users to specify the exact bits they want in the floating
4000 hex_float (float_type
, bytes
)
4034 as_bad (_("unknown floating type type '%c'"), float_type
);
4038 /* It would be nice if we could go through expression to parse the
4039 hex constant, but if we get a bignum it's a pain to sort it into
4040 the buffer correctly. */
4042 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4046 /* The MRI assembler accepts arbitrary underscores strewn about
4047 through the hex constant, so we ignore them as well. */
4048 if (*input_line_pointer
== '_')
4050 ++input_line_pointer
;
4056 as_warn (_("floating point constant too large"));
4059 d
= hex_value (*input_line_pointer
) << 4;
4060 ++input_line_pointer
;
4061 while (*input_line_pointer
== '_')
4062 ++input_line_pointer
;
4063 if (hex_p (*input_line_pointer
))
4065 d
+= hex_value (*input_line_pointer
);
4066 ++input_line_pointer
;
4068 if (target_big_endian
)
4071 bytes
[length
- i
- 1] = d
;
4077 if (target_big_endian
)
4078 memset (bytes
+ i
, 0, length
- i
);
4080 memset (bytes
, 0, length
- i
);
4088 CONStruct some more frag chars of .floats .ffloats etc.
4089 Makes 0 or more new frags.
4090 If need_pass_2 == 1, no frags are emitted.
4091 This understands only floating literals, not expressions. Sorry.
4093 A floating constant is defined by atof_generic(), except it is preceded
4094 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4095 reading, I decided to be incompatible. This always tries to give you
4096 rounded bits to the precision of the pseudo-op. Former AS did premature
4097 truncatation, restored noisy bits instead of trailing 0s AND gave you
4098 a choice of 2 flavours of noise according to which of 2 floating-point
4099 scanners you directed AS to use.
4101 In: input_line_pointer->whitespace before, or '0' of flonum. */
4104 float_cons (float_type
)
4105 /* Clobbers input_line-pointer, checks end-of-line. */
4106 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4109 int length
; /* Number of chars in an object. */
4110 register char *err
; /* Error from scanning floating literal. */
4111 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4113 if (is_it_end_of_statement ())
4115 demand_empty_rest_of_line ();
4119 #ifdef md_flush_pending_output
4120 md_flush_pending_output ();
4125 /* input_line_pointer->1st char of a flonum (we hope!). */
4128 /* Skip any 0{letter} that may be present. Don't even check if the
4129 letter is legal. Someone may invent a "z" format and this routine
4130 has no use for such information. Lusers beware: you get
4131 diagnostics if your input is ill-conditioned. */
4132 if (input_line_pointer
[0] == '0'
4133 && isalpha ((unsigned char) input_line_pointer
[1]))
4134 input_line_pointer
+= 2;
4136 /* Accept :xxxx, where the x's are hex digits, for a floating
4137 point with the exact digits specified. */
4138 if (input_line_pointer
[0] == ':')
4140 ++input_line_pointer
;
4141 length
= hex_float (float_type
, temp
);
4144 ignore_rest_of_line ();
4150 err
= md_atof (float_type
, temp
, &length
);
4151 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4155 as_bad (_("bad floating literal: %s"), err
);
4156 ignore_rest_of_line ();
4167 #ifdef REPEAT_CONS_EXPRESSIONS
4168 if (*input_line_pointer
== ':')
4170 expressionS count_exp
;
4172 ++input_line_pointer
;
4173 expression (&count_exp
);
4175 if (count_exp
.X_op
!= O_constant
4176 || count_exp
.X_add_number
<= 0)
4177 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4179 count
= count_exp
.X_add_number
;
4183 while (--count
>= 0)
4185 p
= frag_more (length
);
4186 memcpy (p
, temp
, (unsigned int) length
);
4191 while (*input_line_pointer
++ == ',');
4193 /* Put terminator back into stream. */
4194 --input_line_pointer
;
4195 demand_empty_rest_of_line ();
4198 /* Return the size of a LEB128 value. */
4201 sizeof_sleb128 (value
)
4204 register int size
= 0;
4205 register unsigned byte
;
4209 byte
= (value
& 0x7f);
4210 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4211 Fortunately, we can structure things so that the extra work reduces
4212 to a noop on systems that do things "properly". */
4213 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4216 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4217 || ((value
== -1) && ((byte
& 0x40) != 0))));
4223 sizeof_uleb128 (value
)
4226 register int size
= 0;
4227 register unsigned byte
;
4231 byte
= (value
& 0x7f);
4241 sizeof_leb128 (value
, sign
)
4246 return sizeof_sleb128 ((offsetT
) value
);
4248 return sizeof_uleb128 (value
);
4251 /* Output a LEB128 value. */
4254 output_sleb128 (p
, value
)
4258 register char *orig
= p
;
4263 unsigned byte
= (value
& 0x7f);
4265 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4266 Fortunately, we can structure things so that the extra work reduces
4267 to a noop on systems that do things "properly". */
4268 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4270 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4271 || ((value
== -1) && ((byte
& 0x40) != 0))));
4283 output_uleb128 (p
, value
)
4291 unsigned byte
= (value
& 0x7f);
4294 /* More bytes to follow. */
4305 output_leb128 (p
, value
, sign
)
4311 return output_sleb128 (p
, (offsetT
) value
);
4313 return output_uleb128 (p
, value
);
4316 /* Do the same for bignums. We combine sizeof with output here in that
4317 we don't output for NULL values of P. It isn't really as critical as
4318 for "normal" values that this be streamlined. */
4321 output_big_sleb128 (p
, bignum
, size
)
4323 LITTLENUM_TYPE
*bignum
;
4331 /* Strip leading sign extensions off the bignum. */
4332 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4337 if (loaded
< 7 && size
> 0)
4339 val
|= (*bignum
<< loaded
);
4340 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4351 if ((val
== 0 && (byte
& 0x40) == 0)
4352 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4353 && (byte
& 0x40) != 0))
4361 while (byte
& 0x80);
4367 output_big_uleb128 (p
, bignum
, size
)
4369 LITTLENUM_TYPE
*bignum
;
4377 /* Strip leading zeros off the bignum. */
4378 /* XXX: Is this needed? */
4379 while (size
> 0 && bignum
[size
- 1] == 0)
4384 if (loaded
< 7 && size
> 0)
4386 val
|= (*bignum
<< loaded
);
4387 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4396 if (size
> 0 || val
)
4403 while (byte
& 0x80);
4409 output_big_leb128 (p
, bignum
, size
, sign
)
4411 LITTLENUM_TYPE
*bignum
;
4415 return output_big_sleb128 (p
, bignum
, size
);
4417 return output_big_uleb128 (p
, bignum
, size
);
4420 /* Generate the appropriate fragments for a given expression to emit a
4424 emit_leb128_expr (exp
, sign
)
4428 operatorT op
= exp
->X_op
;
4431 if (op
== O_absent
|| op
== O_illegal
)
4433 as_warn (_("zero assumed for missing expression"));
4434 exp
->X_add_number
= 0;
4437 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4439 as_bad (_("floating point number invalid"));
4440 exp
->X_add_number
= 0;
4443 else if (op
== O_register
)
4445 as_warn (_("register value used as expression"));
4449 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
4450 a signal that this is leb128 data. It shouldn't optimize this away. */
4452 if (check_eh_frame (exp
, &nbytes
))
4455 /* Let the backend know that subsequent data may be byte aligned. */
4456 #ifdef md_cons_align
4460 if (op
== O_constant
)
4462 /* If we've got a constant, emit the thing directly right now. */
4464 valueT value
= exp
->X_add_number
;
4468 size
= sizeof_leb128 (value
, sign
);
4469 p
= frag_more (size
);
4470 output_leb128 (p
, value
, sign
);
4472 else if (op
== O_big
)
4474 /* O_big is a different sort of constant. */
4479 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4480 p
= frag_more (size
);
4481 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4485 /* Otherwise, we have to create a variable sized fragment and
4486 resolve things later. */
4488 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4489 make_expr_symbol (exp
), 0, (char *) NULL
);
4493 /* Parse the .sleb128 and .uleb128 pseudos. */
4504 emit_leb128_expr (&exp
, sign
);
4506 while (*input_line_pointer
++ == ',');
4508 input_line_pointer
--;
4509 demand_empty_rest_of_line ();
4512 /* We read 0 or more ',' separated, double-quoted strings.
4513 Caller should have checked need_pass_2 is FALSE because we don't
4517 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4518 /* Checks end-of-line. */
4519 register int append_zero
; /* 0: don't append '\0', else 1. */
4521 register unsigned int c
;
4524 #ifdef md_flush_pending_output
4525 md_flush_pending_output ();
4528 /* The following awkward logic is to parse ZERO or more strings,
4529 comma separated. Recall a string expression includes spaces
4530 before the opening '\"' and spaces after the closing '\"'.
4531 We fake a leading ',' if there is (supposed to be)
4532 a 1st, expression. We keep demanding expressions for each ','. */
4533 if (is_it_end_of_statement ())
4535 c
= 0; /* Skip loop. */
4536 ++input_line_pointer
; /* Compensate for end of loop. */
4540 c
= ','; /* Do loop. */
4542 while (c
== ',' || c
== '<' || c
== '"')
4545 switch (*input_line_pointer
)
4548 ++input_line_pointer
; /*->1st char of string. */
4549 start
= input_line_pointer
;
4550 while (is_a_char (c
= next_char_of_string ()))
4552 FRAG_APPEND_1_CHAR (c
);
4556 FRAG_APPEND_1_CHAR (0);
4558 know (input_line_pointer
[-1] == '\"');
4562 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4563 will emit .string with a filename in the .debug section
4564 after a sequence of constants. See the comment in
4565 emit_expr for the sequence. emit_expr will set
4566 dwarf_file_string to non-zero if this string might be a
4567 source file name. */
4568 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4569 dwarf_file_string
= 0;
4570 else if (dwarf_file_string
)
4572 c
= input_line_pointer
[-1];
4573 input_line_pointer
[-1] = '\0';
4574 listing_source_file (start
);
4575 input_line_pointer
[-1] = c
;
4582 input_line_pointer
++;
4583 c
= get_single_number ();
4584 FRAG_APPEND_1_CHAR (c
);
4585 if (*input_line_pointer
!= '>')
4587 as_bad (_("expected <nn>"));
4589 input_line_pointer
++;
4592 input_line_pointer
++;
4596 c
= *input_line_pointer
;
4599 demand_empty_rest_of_line ();
4602 /* FIXME-SOMEDAY: I had trouble here on characters with the
4603 high bits set. We'll probably also have trouble with
4604 multibyte chars, wide chars, etc. Also be careful about
4605 returning values bigger than 1 byte. xoxorich. */
4608 next_char_of_string ()
4610 register unsigned int c
;
4612 c
= *input_line_pointer
++ & CHAR_MASK
;
4620 as_warn (_("unterminated string; newline inserted"));
4621 bump_line_counters ();
4624 #ifndef NO_STRING_ESCAPES
4626 switch (c
= *input_line_pointer
++)
4654 break; /* As itself. */
4670 for (i
= 0, number
= 0;
4671 isdigit (c
) && i
< 3;
4672 c
= *input_line_pointer
++, i
++)
4674 number
= number
* 8 + c
- '0';
4679 --input_line_pointer
;
4688 c
= *input_line_pointer
++;
4689 while (isxdigit (c
))
4692 number
= number
* 16 + c
- '0';
4693 else if (isupper (c
))
4694 number
= number
* 16 + c
- 'A' + 10;
4696 number
= number
* 16 + c
- 'a' + 10;
4697 c
= *input_line_pointer
++;
4700 --input_line_pointer
;
4705 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4706 as_warn (_("unterminated string; newline inserted"));
4708 bump_line_counters ();
4713 #ifdef ONLY_STANDARD_ESCAPES
4714 as_bad (_("bad escaped character in string"));
4716 #endif /* ONLY_STANDARD_ESCAPES */
4721 #endif /* ! defined (NO_STRING_ESCAPES) */
4730 get_segmented_expression (expP
)
4731 register expressionS
*expP
;
4733 register segT retval
;
4735 retval
= expression (expP
);
4736 if (expP
->X_op
== O_illegal
4737 || expP
->X_op
== O_absent
4738 || expP
->X_op
== O_big
)
4740 as_bad (_("expected address expression"));
4741 expP
->X_op
= O_constant
;
4742 expP
->X_add_number
= 0;
4743 retval
= absolute_section
;
4749 get_known_segmented_expression (expP
)
4750 register expressionS
*expP
;
4752 register segT retval
;
4754 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4756 /* There is no easy way to extract the undefined symbol from the
4758 if (expP
->X_add_symbol
!= NULL
4759 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4760 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4761 S_GET_NAME (expP
->X_add_symbol
));
4763 as_warn (_("some symbol undefined; zero assumed"));
4764 retval
= absolute_section
;
4765 expP
->X_op
= O_constant
;
4766 expP
->X_add_number
= 0;
4768 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4773 get_absolute_expression ()
4778 if (exp
.X_op
!= O_constant
)
4780 if (exp
.X_op
!= O_absent
)
4781 as_bad (_("bad or irreducible absolute expression"));
4782 exp
.X_add_number
= 0;
4784 return exp
.X_add_number
;
4787 char /* Return terminator. */
4788 get_absolute_expression_and_terminator (val_pointer
)
4789 long *val_pointer
; /* Return value of expression. */
4791 /* FIXME: val_pointer should probably be offsetT *. */
4792 *val_pointer
= (long) get_absolute_expression ();
4793 return (*input_line_pointer
++);
4796 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4797 Give a warning if that happens. */
4800 demand_copy_C_string (len_pointer
)
4805 if ((s
= demand_copy_string (len_pointer
)) != 0)
4809 for (len
= *len_pointer
; len
> 0; len
--)
4816 as_bad (_("this string may not contain \'\\0\'"));
4824 /* Demand string, but return a safe (=private) copy of the string.
4825 Return NULL if we can't read a string here. */
4828 demand_copy_string (lenP
)
4831 register unsigned int c
;
4837 if (*input_line_pointer
== '\"')
4839 input_line_pointer
++; /* Skip opening quote. */
4841 while (is_a_char (c
= next_char_of_string ()))
4843 obstack_1grow (¬es
, c
);
4846 /* JF this next line is so demand_copy_C_string will return a
4847 null terminated string. */
4848 obstack_1grow (¬es
, '\0');
4849 retval
= obstack_finish (¬es
);
4853 as_warn (_("missing string"));
4855 ignore_rest_of_line ();
4861 /* In: Input_line_pointer->next character.
4863 Do: Skip input_line_pointer over all whitespace.
4865 Out: 1 if input_line_pointer->end-of-line. */
4868 is_it_end_of_statement ()
4871 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4875 equals (sym_name
, reassign
)
4879 register symbolS
*symbolP
; /* Symbol we are working with. */
4883 input_line_pointer
++;
4884 if (*input_line_pointer
== '=')
4885 input_line_pointer
++;
4887 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4888 input_line_pointer
++;
4891 stop
= mri_comment_field (&stopc
);
4893 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4895 /* Turn '. = mumble' into a .org mumble. */
4896 register segT segment
;
4899 segment
= get_known_segmented_expression (&exp
);
4901 do_org (segment
, &exp
, 0);
4908 symbolP
= symbol_find (sym_name
);
4909 local
= symbolP
== NULL
;
4911 #endif /* OBJ_COFF */
4912 symbolP
= symbol_find_or_make (sym_name
);
4913 /* Permit register names to be redefined. */
4915 && S_IS_DEFINED (symbolP
)
4916 && S_GET_SEGMENT (symbolP
) != reg_section
)
4917 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
4920 /* "set" symbols are local unless otherwise specified. */
4922 SF_SET_LOCAL (symbolP
);
4923 #endif /* OBJ_COFF */
4925 pseudo_set (symbolP
);
4930 /* Check garbage after the expression. */
4931 ignore_rest_of_line ();
4932 mri_comment_end (stop
, stopc
);
4936 /* .incbin -- include a file verbatim at the current location. */
4940 int x ATTRIBUTE_UNUSED
;
4951 #ifdef md_flush_pending_output
4952 md_flush_pending_output ();
4956 filename
= demand_copy_string (& len
);
4957 if (filename
== NULL
)
4962 /* Look for optional skip and count. */
4963 if (* input_line_pointer
== ',')
4965 ++ input_line_pointer
;
4966 skip
= get_absolute_expression ();
4970 if (* input_line_pointer
== ',')
4972 ++ input_line_pointer
;
4974 count
= get_absolute_expression ();
4976 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
4982 demand_empty_rest_of_line ();
4984 /* Try opening absolute path first, then try include dirs. */
4985 binfile
= fopen (filename
, FOPEN_RB
);
4986 if (binfile
== NULL
)
4990 path
= xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
4992 for (i
= 0; i
< include_dir_count
; i
++)
4994 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
4996 binfile
= fopen (path
, FOPEN_RB
);
4997 if (binfile
!= NULL
)
5001 if (binfile
== NULL
)
5002 as_bad (_("file not found: %s"), filename
);
5005 path
= xstrdup (filename
);
5011 register_dependency (path
);
5013 /* Compute the length of the file. */
5014 if (fseek (binfile
, 0, SEEK_END
) != 0)
5016 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
5019 file_len
= ftell (binfile
);
5021 /* If a count was not specified use the size of the file. */
5025 if (skip
+ count
> file_len
)
5027 as_bad (_("skip (%ld) + count (%ld) larger than file size (%ld)"),
5028 skip
, count
, file_len
);
5032 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
5034 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
5038 /* Allocate frag space and store file contents in it. */
5039 binfrag
= frag_more (count
);
5041 bytes
= fread (binfrag
, 1, count
, binfile
);
5043 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5044 path
, bytes
, count
);
5047 if (binfile
!= NULL
)
5053 /* .include -- include a file at this point. */
5057 int arg ATTRIBUTE_UNUSED
;
5066 filename
= demand_copy_string (&i
);
5067 if (filename
== NULL
)
5069 /* demand_copy_string has already printed an error and
5070 called ignore_rest_of_line. */
5078 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5079 && *input_line_pointer
!= ' '
5080 && *input_line_pointer
!= '\t')
5082 obstack_1grow (¬es
, *input_line_pointer
);
5083 ++input_line_pointer
;
5087 obstack_1grow (¬es
, '\0');
5088 filename
= obstack_finish (¬es
);
5089 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5090 ++input_line_pointer
;
5093 demand_empty_rest_of_line ();
5094 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
5096 for (i
= 0; i
< include_dir_count
; i
++)
5098 strcpy (path
, include_dirs
[i
]);
5100 strcat (path
, filename
);
5101 if (0 != (try = fopen (path
, FOPEN_RT
)))
5111 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5112 register_dependency (path
);
5113 input_scrub_insert_file (path
);
5117 add_include_dir (path
)
5122 if (include_dir_count
== 0)
5124 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5125 include_dirs
[0] = "."; /* Current dir. */
5126 include_dir_count
= 2;
5130 include_dir_count
++;
5132 (char **) realloc (include_dirs
,
5133 include_dir_count
* sizeof (*include_dirs
));
5136 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5139 if (i
> include_dir_maxlen
)
5140 include_dir_maxlen
= i
;
5143 /* Output debugging information to denote the source file. */
5146 generate_file_debug ()
5148 if (debug_type
== DEBUG_STABS
)
5149 stabs_generate_asm_file ();
5152 /* Output line number debugging information for the current source line. */
5155 generate_lineno_debug ()
5159 case DEBUG_UNSPECIFIED
:
5164 stabs_generate_asm_lineno ();
5167 ecoff_generate_asm_lineno ();
5170 /* ??? We could here indicate to dwarf2dbg.c that something
5171 has changed. However, since there is additional backend
5172 support that is required (calling dwarf2_emit_insn), we
5173 let dwarf2dbg.c call as_where on its own. */
5178 /* Output debugging information to mark a function entry point or end point.
5179 END_P is zero for .func, and non-zero for .endfunc. */
5185 do_s_func (end_p
, NULL
);
5188 /* Subroutine of s_func so targets can choose a different default prefix.
5189 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5192 do_s_func (end_p
, default_prefix
)
5194 const char *default_prefix
;
5196 /* Record the current function so that we can issue an error message for
5197 misplaced .func,.endfunc, and also so that .endfunc needs no
5199 static char *current_name
;
5200 static char *current_label
;
5204 if (current_name
== NULL
)
5206 as_bad (_("missing .func"));
5207 ignore_rest_of_line ();
5211 if (debug_type
== DEBUG_STABS
)
5212 stabs_generate_asm_endfunc (current_name
, current_label
);
5214 current_name
= current_label
= NULL
;
5219 char delim1
, delim2
;
5221 if (current_name
!= NULL
)
5223 as_bad (_(".endfunc missing for previous .func"));
5224 ignore_rest_of_line ();
5228 name
= input_line_pointer
;
5229 delim1
= get_symbol_end ();
5230 name
= xstrdup (name
);
5231 *input_line_pointer
= delim1
;
5233 if (*input_line_pointer
!= ',')
5236 asprintf (&label
, "%s%s", default_prefix
, name
);
5239 char leading_char
= 0;
5240 #ifdef BFD_ASSEMBLER
5241 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5243 /* Missing entry point, use function's name with the leading
5246 asprintf (&label
, "%c%s", leading_char
, name
);
5253 ++input_line_pointer
;
5255 label
= input_line_pointer
;
5256 delim2
= get_symbol_end ();
5257 label
= xstrdup (label
);
5258 *input_line_pointer
= delim2
;
5261 if (debug_type
== DEBUG_STABS
)
5262 stabs_generate_asm_func (name
, label
);
5264 current_name
= name
;
5265 current_label
= label
;
5268 demand_empty_rest_of_line ();
5273 int arg ATTRIBUTE_UNUSED
;
5275 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5277 ++input_line_pointer
;
5279 ++input_line_pointer
;
5283 read_print_statistics (file
)
5286 hash_print_statistics (file
, "pseudo-op table", po_hash
);
5289 /* Inserts the given line into the input stream.
5291 This call avoids macro/conditionals nesting checking, since the contents of
5292 the line are assumed to replace the contents of a line already scanned.
5294 An appropriate use of this function would be substition of input lines when
5295 called by md_start_line_hook(). The given line is assumed to already be
5296 properly scrubbed. */
5299 input_scrub_insert_line (line
)
5304 sb_add_string (&newline
, line
);
5305 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
5307 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
5310 /* Insert a file into the input stream; the path must resolve to an actual
5311 file; no include path searching or dependency registering is performed. */
5314 input_scrub_insert_file (path
)
5317 input_scrub_include_file (path
, input_line_pointer
);
5318 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);