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 /* as_warn (_("Junk character %d."),c); Now done by ignore_rest. */
1057 input_line_pointer
--; /* 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_bad (_("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
;
1357 if (*input_line_pointer
!= ',')
1359 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1360 ignore_rest_of_line ();
1362 mri_comment_end (stop
, stopc
);
1366 input_line_pointer
++; /* skip ',' */
1368 if ((temp
= get_absolute_expression ()) < 0)
1370 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
1371 ignore_rest_of_line ();
1373 mri_comment_end (stop
, stopc
);
1378 symbolP
= symbol_find_or_make (name
);
1381 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1383 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1384 S_GET_NAME (symbolP
));
1385 ignore_rest_of_line ();
1387 mri_comment_end (stop
, stopc
);
1391 if (S_GET_VALUE (symbolP
))
1393 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1394 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
1395 S_GET_NAME (symbolP
),
1396 (long) S_GET_VALUE (symbolP
),
1401 S_SET_VALUE (symbolP
, (valueT
) temp
);
1402 S_SET_EXTERNAL (symbolP
);
1406 extern int flag_one
;
1407 if (!temp
|| !flag_one
)
1408 S_GET_OTHER(symbolP
) = const_flag
;
1410 #endif /* not OBJ_VMS */
1411 know (symbolP
->sy_frag
== &zero_address_frag
);
1413 demand_empty_rest_of_line ();
1416 mri_comment_end (stop
, stopc
);
1419 /* The MRI COMMON pseudo-op. We handle this by creating a common
1420 symbol with the appropriate name. We make s_space do the right
1421 thing by increasing the size. */
1424 s_mri_common (small
)
1425 int small ATTRIBUTE_UNUSED
;
1441 stop
= mri_comment_field (&stopc
);
1445 name
= input_line_pointer
;
1446 if (!isdigit ((unsigned char) *name
))
1447 c
= get_symbol_end ();
1452 ++input_line_pointer
;
1454 while (isdigit ((unsigned char) *input_line_pointer
));
1456 c
= *input_line_pointer
;
1457 *input_line_pointer
= '\0';
1459 if (line_label
!= NULL
)
1461 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1462 + (input_line_pointer
- name
)
1464 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1469 sym
= symbol_find_or_make (name
);
1470 *input_line_pointer
= c
;
1474 if (*input_line_pointer
!= ',')
1478 ++input_line_pointer
;
1479 align
= get_absolute_expression ();
1482 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1484 as_bad (_("attempt to re-define symbol `%s'"), S_GET_NAME (sym
));
1485 ignore_rest_of_line ();
1486 mri_comment_end (stop
, stopc
);
1490 S_SET_EXTERNAL (sym
);
1491 mri_common_symbol
= sym
;
1495 S_SET_ALIGN (sym
, align
);
1498 if (line_label
!= NULL
)
1501 exp
.X_op
= O_symbol
;
1502 exp
.X_add_symbol
= sym
;
1503 exp
.X_add_number
= 0;
1504 symbol_set_value_expression (line_label
, &exp
);
1505 symbol_set_frag (line_label
, &zero_address_frag
);
1506 S_SET_SEGMENT (line_label
, expr_section
);
1509 /* FIXME: We just ignore the small argument, which distinguishes
1510 COMMON and COMMON.S. I don't know what we can do about it. */
1512 /* Ignore the type and hptype. */
1513 if (*input_line_pointer
== ',')
1514 input_line_pointer
+= 2;
1515 if (*input_line_pointer
== ',')
1516 input_line_pointer
+= 2;
1518 demand_empty_rest_of_line ();
1520 mri_comment_end (stop
, stopc
);
1525 int ignore ATTRIBUTE_UNUSED
;
1530 temp
= get_absolute_expression ();
1531 if (flag_readonly_data_in_text
)
1533 section
= text_section
;
1537 section
= data_section
;
1539 subseg_set (section
, (subsegT
) temp
);
1544 demand_empty_rest_of_line ();
1547 /* Handle the .appfile pseudo-op. This is automatically generated by
1548 do_scrub_chars when a preprocessor # line comment is seen with a
1549 file name. This default definition may be overridden by the object
1550 or CPU specific pseudo-ops. This function is also the default
1551 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1555 s_app_file (appfile
)
1561 /* Some assemblers tolerate immediately following '"'. */
1562 if ((s
= demand_copy_string (&length
)) != 0)
1564 /* If this is a fake .appfile, a fake newline was inserted into
1565 the buffer. Passing -2 to new_logical_line tells it to
1568 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1570 /* In MRI mode, the preprocessor may have inserted an extraneous
1573 && *input_line_pointer
== '\''
1574 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1575 ++input_line_pointer
;
1577 demand_empty_rest_of_line ();
1582 listing_source_file (s
);
1584 register_dependency (s
);
1592 /* Handle the .appline pseudo-op. This is automatically generated by
1593 do_scrub_chars when a preprocessor # line comment is seen. This
1594 default definition may be overridden by the object or CPU specific
1599 int ignore ATTRIBUTE_UNUSED
;
1603 /* The given number is that of the next line. */
1604 l
= get_absolute_expression () - 1;
1606 /* Some of the back ends can't deal with non-positive line numbers.
1607 Besides, it's silly. */
1608 as_warn (_("Line numbers must be positive; line number %d rejected."),
1612 new_logical_line ((char *) NULL
, l
);
1615 listing_source_line (l
);
1618 demand_empty_rest_of_line ();
1621 /* Handle the .end pseudo-op. Actually, the real work is done in
1622 read_a_source_file. */
1626 int ignore ATTRIBUTE_UNUSED
;
1630 /* The MRI assembler permits the start symbol to follow .end,
1631 but we don't support that. */
1633 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1634 && *input_line_pointer
!= '*'
1635 && *input_line_pointer
!= '!')
1636 as_warn (_("start address not supported"));
1640 /* Handle the .err pseudo-op. */
1644 int ignore ATTRIBUTE_UNUSED
;
1646 as_bad (_(".err encountered"));
1647 demand_empty_rest_of_line ();
1650 /* Handle the MRI fail pseudo-op. */
1654 int ignore ATTRIBUTE_UNUSED
;
1661 stop
= mri_comment_field (&stopc
);
1663 temp
= get_absolute_expression ();
1665 as_warn (_(".fail %ld encountered"), (long) temp
);
1667 as_bad (_(".fail %ld encountered"), (long) temp
);
1669 demand_empty_rest_of_line ();
1672 mri_comment_end (stop
, stopc
);
1677 int ignore ATTRIBUTE_UNUSED
;
1679 expressionS rep_exp
;
1681 register long fill
= 0;
1684 #ifdef md_flush_pending_output
1685 md_flush_pending_output ();
1688 get_known_segmented_expression (&rep_exp
);
1689 if (*input_line_pointer
== ',')
1691 input_line_pointer
++;
1692 size
= get_absolute_expression ();
1693 if (*input_line_pointer
== ',')
1695 input_line_pointer
++;
1696 fill
= get_absolute_expression ();
1700 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1701 #define BSD_FILL_SIZE_CROCK_8 (8)
1702 if (size
> BSD_FILL_SIZE_CROCK_8
)
1704 as_warn (_(".fill size clamped to %d."), BSD_FILL_SIZE_CROCK_8
);
1705 size
= BSD_FILL_SIZE_CROCK_8
;
1709 as_warn (_("Size negative: .fill ignored."));
1712 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1714 if (rep_exp
.X_add_number
< 0)
1715 as_warn (_("Repeat < 0, .fill ignored"));
1719 if (size
&& !need_pass_2
)
1721 if (rep_exp
.X_op
== O_constant
)
1723 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1724 (relax_substateT
) 0, (symbolS
*) 0,
1725 (offsetT
) rep_exp
.X_add_number
,
1730 /* We don't have a constant repeat count, so we can't use
1731 rs_fill. We can get the same results out of rs_space,
1732 but its argument is in bytes, so we must multiply the
1733 repeat count by size. */
1736 rep_sym
= make_expr_symbol (&rep_exp
);
1739 expressionS size_exp
;
1740 size_exp
.X_op
= O_constant
;
1741 size_exp
.X_add_number
= size
;
1743 rep_exp
.X_op
= O_multiply
;
1744 rep_exp
.X_add_symbol
= rep_sym
;
1745 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1746 rep_exp
.X_add_number
= 0;
1747 rep_sym
= make_expr_symbol (&rep_exp
);
1750 p
= frag_var (rs_space
, (int) size
, (int) size
,
1751 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1754 memset (p
, 0, (unsigned int) size
);
1756 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1757 flavoured AS. The following bizarre behaviour is to be
1758 compatible with above. I guess they tried to take up to 8
1759 bytes from a 4-byte expression and they forgot to sign
1761 #define BSD_FILL_SIZE_CROCK_4 (4)
1762 md_number_to_chars (p
, (valueT
) fill
,
1763 (size
> BSD_FILL_SIZE_CROCK_4
1764 ? BSD_FILL_SIZE_CROCK_4
1766 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1767 but emits no error message because it seems a legal thing to do.
1768 It is a degenerate case of .fill but could be emitted by a
1771 demand_empty_rest_of_line ();
1776 int ignore ATTRIBUTE_UNUSED
;
1785 stop
= mri_comment_field (&stopc
);
1789 name
= input_line_pointer
;
1790 c
= get_symbol_end ();
1791 symbolP
= symbol_find_or_make (name
);
1792 S_SET_EXTERNAL (symbolP
);
1794 *input_line_pointer
= c
;
1796 c
= *input_line_pointer
;
1799 input_line_pointer
++;
1801 if (*input_line_pointer
== '\n')
1807 demand_empty_rest_of_line ();
1810 mri_comment_end (stop
, stopc
);
1813 /* Handle the MRI IRP and IRPC pseudo-ops. */
1825 as_where (&file
, &line
);
1828 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1829 sb_add_char (&s
, *input_line_pointer
++);
1833 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1835 as_bad_where (file
, line
, "%s", err
);
1839 input_scrub_include_sb (&out
, input_line_pointer
, 1);
1841 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1844 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1845 the section to only be linked once. However, this is not supported
1846 by most object file formats. This takes an optional argument,
1847 which is what to do about duplicates. */
1851 int ignore ATTRIBUTE_UNUSED
;
1853 enum linkonce_type type
;
1857 type
= LINKONCE_DISCARD
;
1859 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1864 s
= input_line_pointer
;
1865 c
= get_symbol_end ();
1866 if (strcasecmp (s
, "discard") == 0)
1867 type
= LINKONCE_DISCARD
;
1868 else if (strcasecmp (s
, "one_only") == 0)
1869 type
= LINKONCE_ONE_ONLY
;
1870 else if (strcasecmp (s
, "same_size") == 0)
1871 type
= LINKONCE_SAME_SIZE
;
1872 else if (strcasecmp (s
, "same_contents") == 0)
1873 type
= LINKONCE_SAME_CONTENTS
;
1875 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1877 *input_line_pointer
= c
;
1880 #ifdef obj_handle_link_once
1881 obj_handle_link_once (type
);
1882 #else /* ! defined (obj_handle_link_once) */
1883 #ifdef BFD_ASSEMBLER
1887 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1888 as_warn (_(".linkonce is not supported for this object file format"));
1890 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1891 flags
|= SEC_LINK_ONCE
;
1896 case LINKONCE_DISCARD
:
1897 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1899 case LINKONCE_ONE_ONLY
:
1900 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1902 case LINKONCE_SAME_SIZE
:
1903 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1905 case LINKONCE_SAME_CONTENTS
:
1906 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1909 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1910 as_bad (_("bfd_set_section_flags: %s"),
1911 bfd_errmsg (bfd_get_error ()));
1913 #else /* ! defined (BFD_ASSEMBLER) */
1914 as_warn (_(".linkonce is not supported for this object file format"));
1915 #endif /* ! defined (BFD_ASSEMBLER) */
1916 #endif /* ! defined (obj_handle_link_once) */
1918 demand_empty_rest_of_line ();
1922 s_lcomm_internal (needs_align
, bytes_p
)
1923 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1924 (alignment); 0 if it was an ".lcomm" (2 args only). */
1926 /* 1 if the alignment value should be interpreted as the byte boundary,
1927 rather than the power of 2. */
1930 register char *name
;
1934 register symbolS
*symbolP
;
1935 segT current_seg
= now_seg
;
1936 subsegT current_subseg
= now_subseg
;
1937 const int max_alignment
= 15;
1939 segT bss_seg
= bss_section
;
1941 name
= input_line_pointer
;
1942 c
= get_symbol_end ();
1943 p
= input_line_pointer
;
1947 /* Accept an optional comma after the name. The comma used to be
1948 required, but Irix 5 cc does not generate it. */
1949 if (*input_line_pointer
== ',')
1951 ++input_line_pointer
;
1955 if (*input_line_pointer
== '\n')
1957 as_bad (_("Missing size expression"));
1961 if ((temp
= get_absolute_expression ()) < 0)
1963 as_warn (_("BSS length (%d.) <0! Ignored."), temp
);
1964 ignore_rest_of_line ();
1968 #if defined (TC_MIPS) || defined (TC_ALPHA)
1969 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1970 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1972 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1973 if (temp
<= bfd_get_gp_size (stdoutput
))
1975 bss_seg
= subseg_new (".sbss", 1);
1976 seg_info (bss_seg
)->bss
= 1;
1977 #ifdef BFD_ASSEMBLER
1978 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1979 as_warn (_("error setting flags for \".sbss\": %s"),
1980 bfd_errmsg (bfd_get_error ()));
1988 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
1990 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
1992 record_alignment (bss_seg
, align
);
2000 if (*input_line_pointer
!= ',')
2002 as_bad (_("Expected comma after size"));
2003 ignore_rest_of_line ();
2007 input_line_pointer
++;
2010 if (*input_line_pointer
== '\n')
2012 as_bad (_("Missing alignment"));
2016 align
= get_absolute_expression ();
2020 /* Convert to a power of 2. */
2025 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2028 as_bad (_("Alignment not a power of 2"));
2033 if (align
> max_alignment
)
2035 align
= max_alignment
;
2036 as_warn (_("Alignment too large: %d. assumed."), align
);
2041 as_warn (_("Alignment negative. 0 assumed."));
2044 record_alignment (bss_seg
, align
);
2048 /* Assume some objects may require alignment on some systems. */
2049 #if defined (TC_ALPHA) && ! defined (VMS)
2052 align
= ffs (temp
) - 1;
2053 if (temp
% (1 << align
))
2060 symbolP
= symbol_find_or_make (name
);
2064 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2065 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2066 #ifdef BFD_ASSEMBLER
2067 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2068 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2070 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2073 (S_GET_SEGMENT (symbolP
) == bss_seg
2074 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2078 subseg_set (bss_seg
, 1);
2081 frag_align (align
, 0, 0);
2083 /* Detach from old frag. */
2084 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2085 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2087 symbol_set_frag (symbolP
, frag_now
);
2088 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2089 (offsetT
) temp
, (char *) 0);
2092 S_SET_SEGMENT (symbolP
, bss_seg
);
2095 /* The symbol may already have been created with a preceding
2096 ".globl" directive -- be careful not to step on storage class
2097 in that case. Otherwise, set it to static. */
2098 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2100 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2102 #endif /* OBJ_COFF */
2105 S_SET_SIZE (symbolP
, temp
);
2109 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
2110 S_GET_NAME (symbolP
));
2112 subseg_set (current_seg
, current_subseg
);
2114 demand_empty_rest_of_line ();
2118 s_lcomm (needs_align
)
2121 s_lcomm_internal (needs_align
, 0);
2125 s_lcomm_bytes (needs_align
)
2128 s_lcomm_internal (needs_align
, 1);
2133 int ignore ATTRIBUTE_UNUSED
;
2135 register char *name
;
2139 register symbolS
*symbolP
;
2141 /* We permit ANY defined expression: BSD4.2 demands constants. */
2142 name
= input_line_pointer
;
2143 c
= get_symbol_end ();
2144 p
= input_line_pointer
;
2148 if (*input_line_pointer
!= ',')
2151 as_bad (_("Expected comma after name \"%s\""), name
);
2153 ignore_rest_of_line ();
2157 input_line_pointer
++;
2160 if (exp
.X_op
!= O_constant
2161 && exp
.X_op
!= O_register
)
2163 as_bad (_("bad expression"));
2164 ignore_rest_of_line ();
2169 symbolP
= symbol_find_or_make (name
);
2171 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2172 symbolP->sy_desc == 0) out of this test because coff doesn't have
2173 those fields, and I can't see when they'd ever be tripped. I
2174 don't think I understand why they were here so I may have
2175 introduced a bug. As recently as 1.37 didn't have this test
2176 anyway. xoxorich. */
2178 if (S_GET_SEGMENT (symbolP
) == undefined_section
2179 && S_GET_VALUE (symbolP
) == 0)
2181 /* The name might be an undefined .global symbol; be sure to
2182 keep the "external" bit. */
2183 S_SET_SEGMENT (symbolP
,
2184 (exp
.X_op
== O_constant
2187 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2191 as_bad (_("Symbol %s already defined"), name
);
2195 demand_empty_rest_of_line ();
2198 /* Read a line into an sb. */
2204 char quote1
, quote2
, inquote
;
2206 if (input_line_pointer
[-1] == '\n')
2207 bump_line_counters ();
2209 if (input_line_pointer
>= buffer_limit
)
2211 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2212 if (buffer_limit
== 0)
2216 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2217 code needs to be changed. */
2226 #ifdef LEX_IS_STRINGQUOTE
2232 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2233 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2235 if (inquote
== *input_line_pointer
)
2237 else if (inquote
== '\0')
2239 if (*input_line_pointer
== quote1
)
2241 else if (*input_line_pointer
== quote2
)
2245 sb_add_char (line
, *input_line_pointer
++);
2248 while (input_line_pointer
< buffer_limit
2249 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2251 if (input_line_pointer
[-1] == '\n')
2252 bump_line_counters ();
2253 ++input_line_pointer
;
2259 /* Define a macro. This is an interface to macro.c, which is shared
2260 between gas and gasp. */
2264 int ignore ATTRIBUTE_UNUSED
;
2273 as_where (&file
, &line
);
2276 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2277 sb_add_char (&s
, *input_line_pointer
++);
2280 if (line_label
!= NULL
)
2281 sb_add_string (&label
, S_GET_NAME (line_label
));
2283 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2285 as_bad_where (file
, line
, "%s", err
);
2288 if (line_label
!= NULL
)
2290 S_SET_SEGMENT (line_label
, undefined_section
);
2291 S_SET_VALUE (line_label
, 0);
2292 symbol_set_frag (line_label
, &zero_address_frag
);
2295 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2296 && hash_find (po_hash
, name
) != NULL
)
2299 && hash_find (po_hash
, name
+ 1) != NULL
))
2300 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2307 /* Handle the .mexit pseudo-op, which immediately exits a macro
2312 int ignore ATTRIBUTE_UNUSED
;
2314 cond_exit_macro (macro_nest
);
2315 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2318 /* Switch in and out of MRI mode. */
2322 int ignore ATTRIBUTE_UNUSED
;
2326 on
= get_absolute_expression ();
2327 old_flag
= flag_mri
;
2345 /* Operator precedence changes in m68k MRI mode, so we need to
2346 update the operator rankings. */
2347 expr_set_precedence ();
2349 #ifdef MRI_MODE_CHANGE
2351 MRI_MODE_CHANGE (on
);
2354 demand_empty_rest_of_line ();
2357 /* Handle changing the location counter. */
2360 do_org (segment
, exp
, fill
)
2365 if (segment
!= now_seg
&& segment
!= absolute_section
)
2366 as_bad (_("invalid segment \"%s\"; segment \"%s\" assumed"),
2367 segment_name (segment
), segment_name (now_seg
));
2369 if (now_seg
== absolute_section
)
2372 as_warn (_("ignoring fill value in absolute section"));
2373 if (exp
->X_op
!= O_constant
)
2375 as_bad (_("only constant offsets supported in absolute section"));
2376 exp
->X_add_number
= 0;
2378 abs_section_offset
= exp
->X_add_number
;
2383 symbolS
*sym
= exp
->X_add_symbol
;
2384 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2386 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2388 /* Handle complex expressions. */
2389 sym
= make_expr_symbol (exp
);
2393 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2400 int ignore ATTRIBUTE_UNUSED
;
2402 register segT segment
;
2404 register long temp_fill
;
2406 #ifdef md_flush_pending_output
2407 md_flush_pending_output ();
2410 /* The m68k MRI assembler has a different meaning for .org. It
2411 means to create an absolute section at a given address. We can't
2412 support that--use a linker script instead. */
2415 as_bad (_("MRI style ORG pseudo-op not supported"));
2416 ignore_rest_of_line ();
2420 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2421 thing as a sub-segment-relative origin. Any absolute origin is
2422 given a warning, then assumed to be segment-relative. Any
2423 segmented origin expression ("foo+42") had better be in the right
2424 segment or the .org is ignored.
2426 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2427 we never know sub-segment sizes when we are reading code. BSD
2428 will crash trying to emit negative numbers of filler bytes in
2429 certain .orgs. We don't crash, but see as-write for that code.
2431 Don't make frag if need_pass_2==1. */
2432 segment
= get_known_segmented_expression (&exp
);
2433 if (*input_line_pointer
== ',')
2435 input_line_pointer
++;
2436 temp_fill
= get_absolute_expression ();
2442 do_org (segment
, &exp
, temp_fill
);
2444 demand_empty_rest_of_line ();
2447 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2448 called by the obj-format routine which handles section changing
2449 when in MRI mode. It will create a new section, and return it. It
2450 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2451 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2452 flags will be set in the section. */
2456 char *type ATTRIBUTE_UNUSED
;
2466 name
= input_line_pointer
;
2467 if (!isdigit ((unsigned char) *name
))
2468 c
= get_symbol_end ();
2473 ++input_line_pointer
;
2475 while (isdigit ((unsigned char) *input_line_pointer
));
2477 c
= *input_line_pointer
;
2478 *input_line_pointer
= '\0';
2481 name
= xstrdup (name
);
2483 *input_line_pointer
= c
;
2485 seg
= subseg_new (name
, 0);
2487 if (*input_line_pointer
== ',')
2491 ++input_line_pointer
;
2492 align
= get_absolute_expression ();
2493 record_alignment (seg
, align
);
2497 if (*input_line_pointer
== ',')
2499 c
= *++input_line_pointer
;
2500 c
= toupper ((unsigned char) c
);
2501 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2504 as_bad (_("unrecognized section type"));
2505 ++input_line_pointer
;
2507 #ifdef BFD_ASSEMBLER
2511 flags
= SEC_NO_FLAGS
;
2513 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2514 else if (*type
== 'D' || *type
== 'M')
2515 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2516 else if (*type
== 'R')
2517 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2518 if (flags
!= SEC_NO_FLAGS
)
2520 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2521 as_warn (_("error setting flags for \"%s\": %s"),
2522 bfd_section_name (stdoutput
, seg
),
2523 bfd_errmsg (bfd_get_error ()));
2529 /* Ignore the HP type. */
2530 if (*input_line_pointer
== ',')
2531 input_line_pointer
+= 2;
2533 demand_empty_rest_of_line ();
2535 #else /* ! TC_M68K */
2544 name
= input_line_pointer
;
2545 c
= get_symbol_end ();
2547 name
= xstrdup (name
);
2549 *input_line_pointer
= c
;
2551 seg
= subseg_new (name
, 0);
2553 if (*input_line_pointer
!= ',')
2559 ++input_line_pointer
;
2561 sectype
= input_line_pointer
;
2562 c
= get_symbol_end ();
2563 if (*sectype
== '\0')
2565 else if (strcasecmp (sectype
, "text") == 0)
2567 else if (strcasecmp (sectype
, "data") == 0)
2569 else if (strcasecmp (sectype
, "romdata") == 0)
2572 as_warn (_("unrecognized section type `%s'"), sectype
);
2573 *input_line_pointer
= c
;
2576 if (*input_line_pointer
== ',')
2580 ++input_line_pointer
;
2582 seccmd
= input_line_pointer
;
2583 c
= get_symbol_end ();
2584 if (strcasecmp (seccmd
, "absolute") == 0)
2586 as_bad (_("absolute sections are not supported"));
2587 *input_line_pointer
= c
;
2588 ignore_rest_of_line ();
2591 else if (strcasecmp (seccmd
, "align") == 0)
2595 *input_line_pointer
= c
;
2596 align
= get_absolute_expression ();
2597 record_alignment (seg
, align
);
2601 as_warn (_("unrecognized section command `%s'"), seccmd
);
2602 *input_line_pointer
= c
;
2606 demand_empty_rest_of_line ();
2608 #else /* ! TC_I960 */
2609 /* The MRI assembler seems to use different forms of .sect for
2610 different targets. */
2611 as_bad ("MRI mode not supported for this target");
2612 ignore_rest_of_line ();
2613 #endif /* ! TC_I960 */
2614 #endif /* ! TC_M68K */
2617 /* Handle the .print pseudo-op. */
2621 int ignore ATTRIBUTE_UNUSED
;
2626 s
= demand_copy_C_string (&len
);
2628 demand_empty_rest_of_line ();
2631 /* Handle the .purgem pseudo-op. */
2635 int ignore ATTRIBUTE_UNUSED
;
2637 if (is_it_end_of_statement ())
2639 demand_empty_rest_of_line ();
2649 name
= input_line_pointer
;
2650 c
= get_symbol_end ();
2651 delete_macro (name
);
2652 *input_line_pointer
= c
;
2655 while (*input_line_pointer
++ == ',');
2657 --input_line_pointer
;
2658 demand_empty_rest_of_line ();
2661 /* Handle the .rept pseudo-op. */
2665 int ignore ATTRIBUTE_UNUSED
;
2669 count
= get_absolute_expression ();
2671 do_repeat (count
, "REPT", "ENDR");
2674 /* This function provides a generic repeat block implementation. It allows
2675 different directives to be used as the start/end keys. */
2678 do_repeat (count
, start
, end
)
2687 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2689 as_bad (_("%s without %s"), start
, end
);
2695 sb_add_sb (&many
, &one
);
2699 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2701 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2704 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2705 input buffers to skip. Assumes that conditionals preceding the loop end
2706 are properly nested.
2708 This function makes it easier to implement a premature "break" out of the
2709 loop. The EXTRA arg accounts for other buffers we might have inserted,
2710 such as line substitutions. */
2716 cond_exit_macro (macro_nest
);
2717 while (extra
-- >= 0)
2718 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2721 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2722 this is .equiv, and it is an error if the symbol is already
2729 register char *name
;
2730 register char delim
;
2731 register char *end_name
;
2732 register symbolS
*symbolP
;
2734 /* Especial apologies for the random logic:
2735 this just grew, and could be parsed much more simply!
2737 name
= input_line_pointer
;
2738 delim
= get_symbol_end ();
2739 end_name
= input_line_pointer
;
2741 if (name
[0] == '\0')
2743 as_bad (_("expected symbol name"));
2745 discard_rest_of_line ();
2752 if (*input_line_pointer
!= ',')
2755 as_bad (_("Expected comma after name \"%s\""), name
);
2757 ignore_rest_of_line ();
2761 input_line_pointer
++;
2764 if (name
[0] == '.' && name
[1] == '\0')
2766 /* Turn '. = mumble' into a .org mumble. */
2767 register segT segment
;
2770 segment
= get_known_segmented_expression (&exp
);
2773 do_org (segment
, &exp
, 0);
2779 if ((symbolP
= symbol_find (name
)) == NULL
2780 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2783 /* When doing symbol listings, play games with dummy fragments living
2784 outside the normal fragment chain to record the file and line info
2786 if (listing
& LISTING_SYMBOLS
)
2788 extern struct list_info_struct
*listing_tail
;
2789 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2790 memset (dummy_frag
, 0, sizeof (fragS
));
2791 dummy_frag
->fr_type
= rs_fill
;
2792 dummy_frag
->line
= listing_tail
;
2793 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2794 dummy_frag
->fr_symbol
= symbolP
;
2798 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2801 /* "set" symbols are local unless otherwise specified. */
2802 SF_SET_LOCAL (symbolP
);
2803 #endif /* OBJ_COFF */
2806 symbol_table_insert (symbolP
);
2811 && S_IS_DEFINED (symbolP
)
2812 && S_GET_SEGMENT (symbolP
) != reg_section
)
2813 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
2815 pseudo_set (symbolP
);
2816 demand_empty_rest_of_line ();
2830 #ifdef md_flush_pending_output
2831 md_flush_pending_output ();
2835 stop
= mri_comment_field (&stopc
);
2837 /* In m68k MRI mode, we need to align to a word boundary, unless
2839 if (flag_m68k_mri
&& mult
> 1)
2841 if (now_seg
== absolute_section
)
2843 abs_section_offset
+= abs_section_offset
& 1;
2844 if (line_label
!= NULL
)
2845 S_SET_VALUE (line_label
, abs_section_offset
);
2847 else if (mri_common_symbol
!= NULL
)
2851 val
= S_GET_VALUE (mri_common_symbol
);
2854 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2855 if (line_label
!= NULL
)
2857 expressionS
*symexp
;
2859 symexp
= symbol_get_value_expression (line_label
);
2860 know (symexp
->X_op
== O_symbol
);
2861 know (symexp
->X_add_symbol
== mri_common_symbol
);
2862 symexp
->X_add_number
+= 1;
2868 do_align (1, (char *) NULL
, 0, 0);
2869 if (line_label
!= NULL
)
2871 symbol_set_frag (line_label
, frag_now
);
2872 S_SET_VALUE (line_label
, frag_now_fix ());
2882 if (*input_line_pointer
== ',')
2884 ++input_line_pointer
;
2889 val
.X_op
= O_constant
;
2890 val
.X_add_number
= 0;
2893 if (val
.X_op
!= O_constant
2894 || val
.X_add_number
< - 0x80
2895 || val
.X_add_number
> 0xff
2896 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2898 if (exp
.X_op
!= O_constant
)
2899 as_bad (_("Unsupported variable size or fill value"));
2906 bytes
= mult
* exp
.X_add_number
;
2907 for (i
= 0; i
< exp
.X_add_number
; i
++)
2908 emit_expr (&val
, mult
);
2913 if (exp
.X_op
== O_constant
)
2917 repeat
= exp
.X_add_number
;
2924 as_warn (_(".space repeat count is zero, ignored"));
2925 else if (repeat
< 0)
2926 as_warn (_(".space repeat count is negative, ignored"));
2930 /* If we are in the absolute section, just bump the offset. */
2931 if (now_seg
== absolute_section
)
2933 abs_section_offset
+= repeat
;
2937 /* If we are secretly in an MRI common section, then
2938 creating space just increases the size of the common
2940 if (mri_common_symbol
!= NULL
)
2942 S_SET_VALUE (mri_common_symbol
,
2943 S_GET_VALUE (mri_common_symbol
) + repeat
);
2948 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2949 (offsetT
) repeat
, (char *) 0);
2953 if (now_seg
== absolute_section
)
2955 as_bad (_("space allocation too complex in absolute section"));
2956 subseg_set (text_section
, 0);
2959 if (mri_common_symbol
!= NULL
)
2961 as_bad (_("space allocation too complex in common section"));
2962 mri_common_symbol
= NULL
;
2966 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2967 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2971 *p
= val
.X_add_number
;
2976 /* In MRI mode, after an odd number of bytes, we must align to an
2977 even word boundary, unless the next instruction is a dc.b, ds.b
2979 if (flag_mri
&& (bytes
& 1) != 0)
2980 mri_pending_align
= 1;
2982 demand_empty_rest_of_line ();
2985 mri_comment_end (stop
, stopc
);
2988 /* This is like s_space, but the value is a floating point number with
2989 the given precision. This is for the MRI dcb.s pseudo-op and
2993 s_float_space (float_type
)
2998 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3003 stop
= mri_comment_field (&stopc
);
3005 count
= get_absolute_expression ();
3008 if (*input_line_pointer
!= ',')
3010 as_bad (_("missing value"));
3011 ignore_rest_of_line ();
3013 mri_comment_end (stop
, stopc
);
3017 ++input_line_pointer
;
3021 /* Skip any 0{letter} that may be present. Don't even check if the
3022 * letter is legal. */
3023 if (input_line_pointer
[0] == '0'
3024 && isalpha ((unsigned char) input_line_pointer
[1]))
3025 input_line_pointer
+= 2;
3027 /* Accept :xxxx, where the x's are hex digits, for a floating point
3028 with the exact digits specified. */
3029 if (input_line_pointer
[0] == ':')
3031 flen
= hex_float (float_type
, temp
);
3034 ignore_rest_of_line ();
3036 mri_comment_end (stop
, stopc
);
3044 err
= md_atof (float_type
, temp
, &flen
);
3045 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3049 as_bad (_("Bad floating literal: %s"), err
);
3050 ignore_rest_of_line ();
3052 mri_comment_end (stop
, stopc
);
3057 while (--count
>= 0)
3061 p
= frag_more (flen
);
3062 memcpy (p
, temp
, (unsigned int) flen
);
3065 demand_empty_rest_of_line ();
3068 mri_comment_end (stop
, stopc
);
3071 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3075 int ignore ATTRIBUTE_UNUSED
;
3081 stop
= mri_comment_field (&stopc
);
3082 abs_section_offset
= get_absolute_expression ();
3083 subseg_set (absolute_section
, 0);
3084 demand_empty_rest_of_line ();
3086 mri_comment_end (stop
, stopc
);
3091 int ignore ATTRIBUTE_UNUSED
;
3095 temp
= get_absolute_expression ();
3096 subseg_set (text_section
, (subsegT
) temp
);
3097 demand_empty_rest_of_line ();
3099 const_flag
&= ~IN_DEFAULT_SECTION
;
3104 demand_empty_rest_of_line ()
3107 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3108 input_line_pointer
++;
3110 ignore_rest_of_line ();
3112 /* Return having already swallowed end-of-line. */
3116 ignore_rest_of_line ()
3118 /* For suspect lines: gives warning. */
3119 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3121 if (isprint ((unsigned char) *input_line_pointer
))
3122 as_bad (_("Rest of line ignored. First ignored character is `%c'."),
3123 *input_line_pointer
);
3125 as_bad (_("Rest of line ignored. First ignored character valued 0x%x."),
3126 *input_line_pointer
);
3128 while (input_line_pointer
< buffer_limit
3129 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3130 input_line_pointer
++;
3133 input_line_pointer
++;
3135 /* Return pointing just after end-of-line. */
3136 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3140 discard_rest_of_line ()
3142 while (input_line_pointer
< buffer_limit
3143 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3144 input_line_pointer
++;
3146 input_line_pointer
++;
3148 /* Return pointing just after end-of-line. */
3149 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3152 /* In: Pointer to a symbol.
3153 Input_line_pointer->expression.
3155 Out: Input_line_pointer->just after any whitespace after expression.
3156 Tried to set symbol to value of expression.
3157 Will change symbols type, value, and frag; */
3160 pseudo_set (symbolP
)
3164 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3166 #endif /* OBJ_AOUT or OBJ_BOUT */
3168 know (symbolP
); /* NULL pointer is logic error. */
3169 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3170 ext
= S_IS_EXTERNAL (symbolP
);
3171 #endif /* OBJ_AOUT or OBJ_BOUT */
3173 (void) expression (&exp
);
3175 if (exp
.X_op
== O_illegal
)
3176 as_bad (_("illegal expression; zero assumed"));
3177 else if (exp
.X_op
== O_absent
)
3178 as_bad (_("missing expression; zero assumed"));
3179 else if (exp
.X_op
== O_big
)
3181 if (exp
.X_add_number
> 0)
3182 as_bad (_("bignum invalid; zero assumed"));
3184 as_bad (_("floating point number invalid; zero assumed"));
3186 else if (exp
.X_op
== O_subtract
3187 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3188 == S_GET_SEGMENT (exp
.X_op_symbol
))
3189 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3190 && (symbol_get_frag (exp
.X_add_symbol
)
3191 == symbol_get_frag (exp
.X_op_symbol
)))
3193 exp
.X_op
= O_constant
;
3194 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3195 - S_GET_VALUE (exp
.X_op_symbol
));
3203 exp
.X_add_number
= 0;
3206 S_SET_SEGMENT (symbolP
, absolute_section
);
3207 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3209 S_SET_EXTERNAL (symbolP
);
3211 S_CLEAR_EXTERNAL (symbolP
);
3212 #endif /* OBJ_AOUT or OBJ_BOUT */
3213 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3214 if (exp
.X_op
!= O_constant
)
3215 symbol_set_frag (symbolP
, &zero_address_frag
);
3219 S_SET_SEGMENT (symbolP
, reg_section
);
3220 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3221 symbol_set_frag (symbolP
, &zero_address_frag
);
3225 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3226 || exp
.X_add_number
!= 0)
3227 symbol_set_value_expression (symbolP
, &exp
);
3228 else if (symbol_section_p (symbolP
))
3229 as_bad ("invalid attempt to set value of section symbol");
3232 symbolS
*s
= exp
.X_add_symbol
;
3234 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3235 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3237 S_SET_EXTERNAL (symbolP
);
3239 S_CLEAR_EXTERNAL (symbolP
);
3240 #endif /* OBJ_AOUT or OBJ_BOUT */
3241 S_SET_VALUE (symbolP
,
3242 exp
.X_add_number
+ S_GET_VALUE (s
));
3243 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3244 copy_symbol_attributes (symbolP
, s
);
3249 /* The value is some complex expression.
3250 FIXME: Should we set the segment to anything? */
3251 symbol_set_value_expression (symbolP
, &exp
);
3258 CONStruct more frag of .bytes, or .words etc.
3259 Should need_pass_2 be 1 then emit no frag(s).
3260 This understands EXPRESSIONS.
3264 This has a split personality. We use expression() to read the
3265 value. We can detect if the value won't fit in a byte or word.
3266 But we can't detect if expression() discarded significant digits
3267 in the case of a long. Not worth the crocks required to fix it. */
3269 /* Select a parser for cons expressions. */
3271 /* Some targets need to parse the expression in various fancy ways.
3272 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3273 (for example, the HPPA does this). Otherwise, you can define
3274 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3275 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3276 are defined, which is the normal case, then only simple expressions
3281 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3284 #ifndef TC_PARSE_CONS_EXPRESSION
3285 #ifdef BITFIELD_CONS_EXPRESSIONS
3286 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3288 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3290 #ifdef REPEAT_CONS_EXPRESSIONS
3291 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3293 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3296 /* If we haven't gotten one yet, just call expression. */
3297 #ifndef TC_PARSE_CONS_EXPRESSION
3298 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3302 /* Worker to do .byte etc statements.
3303 Clobbers input_line_pointer and checks end-of-line. */
3306 cons_worker (nbytes
, rva
)
3307 register int nbytes
; /* 1=.byte, 2=.word, 4=.long. */
3315 #ifdef md_flush_pending_output
3316 md_flush_pending_output ();
3320 stop
= mri_comment_field (&stopc
);
3322 if (is_it_end_of_statement ())
3324 demand_empty_rest_of_line ();
3326 mri_comment_end (stop
, stopc
);
3330 #ifdef md_cons_align
3331 md_cons_align (nbytes
);
3339 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3342 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3346 if (exp
.X_op
== O_symbol
)
3347 exp
.X_op
= O_symbol_rva
;
3349 as_fatal (_("rva without symbol"));
3351 emit_expr (&exp
, (unsigned int) nbytes
);
3354 while (*input_line_pointer
++ == ',');
3356 /* In MRI mode, after an odd number of bytes, we must align to an
3357 even word boundary, unless the next instruction is a dc.b, ds.b
3359 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3360 mri_pending_align
= 1;
3362 input_line_pointer
--; /* Put terminator back into stream. */
3364 demand_empty_rest_of_line ();
3367 mri_comment_end (stop
, stopc
);
3374 cons_worker (size
, 0);
3381 cons_worker (size
, 1);
3384 /* Put the contents of expression EXP into the object file using
3385 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3388 emit_expr (exp
, nbytes
)
3390 unsigned int nbytes
;
3394 valueT extra_digit
= 0;
3396 /* Don't do anything if we are going to make another pass. */
3402 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3403 appear as a four byte positive constant in the .line section,
3404 followed by a 2 byte 0xffff. Look for that case here. */
3406 static int dwarf_line
= -1;
3408 if (strcmp (segment_name (now_seg
), ".line") != 0)
3410 else if (dwarf_line
>= 0
3412 && exp
->X_op
== O_constant
3413 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3414 listing_source_line ((unsigned int) dwarf_line
);
3415 else if (nbytes
== 4
3416 && exp
->X_op
== O_constant
3417 && exp
->X_add_number
>= 0)
3418 dwarf_line
= exp
->X_add_number
;
3423 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3424 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3425 AT_sibling (0x12) followed by a four byte address of the sibling
3426 followed by a 2 byte AT_name (0x38) followed by the name of the
3427 file. We look for that case here. */
3429 static int dwarf_file
= 0;
3431 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3433 else if (dwarf_file
== 0
3435 && exp
->X_op
== O_constant
3436 && exp
->X_add_number
== 0x11)
3438 else if (dwarf_file
== 1
3440 && exp
->X_op
== O_constant
3441 && exp
->X_add_number
== 0x12)
3443 else if (dwarf_file
== 2
3446 else if (dwarf_file
== 3
3448 && exp
->X_op
== O_constant
3449 && exp
->X_add_number
== 0x38)
3454 /* The variable dwarf_file_string tells stringer that the string
3455 may be the name of the source file. */
3456 if (dwarf_file
== 4)
3457 dwarf_file_string
= 1;
3459 dwarf_file_string
= 0;
3464 if (check_eh_frame (exp
, &nbytes
))
3469 /* Allow `.word 0' in the absolute section. */
3470 if (now_seg
== absolute_section
)
3472 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3473 as_bad (_("attempt to store value in absolute section"));
3474 abs_section_offset
+= nbytes
;
3478 /* Handle a negative bignum. */
3480 && exp
->X_add_number
== 0
3481 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3482 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3485 unsigned long carry
;
3487 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3489 /* Negate the bignum: one's complement each digit and add 1. */
3491 for (i
= 0; i
< exp
->X_add_number
; i
++)
3495 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3498 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3499 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3502 /* We can ignore any carry out, because it will be handled by
3503 extra_digit if it is needed. */
3505 extra_digit
= (valueT
) -1;
3509 if (op
== O_absent
|| op
== O_illegal
)
3511 as_warn (_("zero assumed for missing expression"));
3512 exp
->X_add_number
= 0;
3515 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3517 as_bad (_("floating point number invalid; zero assumed"));
3518 exp
->X_add_number
= 0;
3521 else if (op
== O_register
)
3523 as_warn (_("register value used as expression"));
3527 p
= frag_more ((int) nbytes
);
3529 #ifndef WORKING_DOT_WORD
3530 /* If we have the difference of two symbols in a word, save it on
3531 the broken_words list. See the code in write.c. */
3532 if (op
== O_subtract
&& nbytes
== 2)
3534 struct broken_word
*x
;
3536 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3537 x
->next_broken_word
= broken_words
;
3540 x
->subseg
= now_subseg
;
3542 x
->word_goes_here
= p
;
3544 x
->add
= exp
->X_add_symbol
;
3545 x
->sub
= exp
->X_op_symbol
;
3546 x
->addnum
= exp
->X_add_number
;
3553 /* If we have an integer, but the number of bytes is too large to
3554 pass to md_number_to_chars, handle it as a bignum. */
3555 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3560 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3561 extra_digit
= (valueT
) -1;
3562 val
= (valueT
) exp
->X_add_number
;
3566 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3567 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3571 op
= exp
->X_op
= O_big
;
3572 exp
->X_add_number
= gencnt
;
3575 if (op
== O_constant
)
3577 register valueT get
;
3578 register valueT use
;
3579 register valueT mask
;
3581 register valueT unmask
;
3583 /* JF << of >= number of bits in the object is undefined. In
3584 particular SPARC (Sun 4) has problems. */
3585 if (nbytes
>= sizeof (valueT
))
3588 if (nbytes
> sizeof (valueT
))
3591 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3595 /* Don't store these bits. */
3596 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3597 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3600 unmask
= ~mask
; /* Do store these bits. */
3603 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3604 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3607 get
= exp
->X_add_number
;
3609 if ((get
& mask
) != 0
3610 && ((get
& mask
) != mask
3611 || (get
& hibit
) == 0))
3612 { /* Leading bits contain both 0s & 1s. */
3613 as_warn (_("Value 0x%lx truncated to 0x%lx."),
3614 (unsigned long) get
, (unsigned long) use
);
3616 /* Put bytes in right order. */
3617 md_number_to_chars (p
, use
, (int) nbytes
);
3619 else if (op
== O_big
)
3622 LITTLENUM_TYPE
*nums
;
3624 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3626 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3629 as_warn (_("Bignum truncated to %d bytes"), nbytes
);
3633 if (target_big_endian
)
3635 while (nbytes
> size
)
3637 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3638 nbytes
-= CHARS_PER_LITTLENUM
;
3639 p
+= CHARS_PER_LITTLENUM
;
3642 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3646 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3647 size
-= CHARS_PER_LITTLENUM
;
3648 p
+= CHARS_PER_LITTLENUM
;
3653 nums
= generic_bignum
;
3656 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3658 size
-= CHARS_PER_LITTLENUM
;
3659 p
+= CHARS_PER_LITTLENUM
;
3660 nbytes
-= CHARS_PER_LITTLENUM
;
3665 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3666 nbytes
-= CHARS_PER_LITTLENUM
;
3667 p
+= CHARS_PER_LITTLENUM
;
3673 memset (p
, 0, nbytes
);
3675 /* Now we need to generate a fixS to record the symbol value.
3676 This is easy for BFD. For other targets it can be more
3677 complex. For very complex cases (currently, the HPPA and
3678 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3679 want. For simpler cases, you can define TC_CONS_RELOC to be
3680 the name of the reloc code that should be stored in the fixS.
3681 If neither is defined, the code uses NO_RELOC if it is
3682 defined, and otherwise uses 0. */
3684 #ifdef BFD_ASSEMBLER
3685 #ifdef TC_CONS_FIX_NEW
3686 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3689 bfd_reloc_code_real_type r
;
3706 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3710 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3715 #ifdef TC_CONS_FIX_NEW
3716 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3718 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3719 it is defined, otherwise use NO_RELOC if it is defined,
3721 #ifndef TC_CONS_RELOC
3723 #define TC_CONS_RELOC NO_RELOC
3725 #define TC_CONS_RELOC 0
3728 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3730 #endif /* TC_CONS_FIX_NEW */
3731 #endif /* BFD_ASSEMBLER */
3735 #ifdef BITFIELD_CONS_EXPRESSIONS
3737 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3738 w:x,y:z, where w and y are bitwidths and x and y are values. They
3739 then pack them all together. We do a little better in that we allow
3740 them in words, longs, etc. and we'll pack them in target byte order
3743 The rules are: pack least significat bit first, if a field doesn't
3744 entirely fit, put it in the next unit. Overflowing the bitfield is
3745 explicitly *not* even a warning. The bitwidth should be considered
3748 To use this function the tc-XXX.h file should define
3749 BITFIELD_CONS_EXPRESSIONS. */
3752 parse_bitfield_cons (exp
, nbytes
)
3754 unsigned int nbytes
;
3756 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3757 char *hold
= input_line_pointer
;
3759 (void) expression (exp
);
3761 if (*input_line_pointer
== ':')
3768 unsigned long width
;
3770 if (*input_line_pointer
!= ':')
3772 input_line_pointer
= hold
;
3774 } /* Next piece is not a bitfield. */
3776 /* In the general case, we can't allow
3777 full expressions with symbol
3778 differences and such. The relocation
3779 entries for symbols not defined in this
3780 assembly would require arbitrary field
3781 widths, positions, and masks which most
3782 of our current object formats don't
3785 In the specific case where a symbol
3786 *is* defined in this assembly, we
3787 *could* build fixups and track it, but
3788 this could lead to confusion for the
3789 backends. I'm lazy. I'll take any
3790 SEG_ABSOLUTE. I think that means that
3791 you can use a previous .set or
3792 .equ type symbol. xoxorich. */
3794 if (exp
->X_op
== O_absent
)
3796 as_warn (_("using a bit field width of zero"));
3797 exp
->X_add_number
= 0;
3798 exp
->X_op
= O_constant
;
3799 } /* Implied zero width bitfield. */
3801 if (exp
->X_op
!= O_constant
)
3803 *input_line_pointer
= '\0';
3804 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3805 *input_line_pointer
= ':';
3806 demand_empty_rest_of_line ();
3808 } /* Too complex. */
3810 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3812 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3813 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3814 width
= BITS_PER_CHAR
* nbytes
;
3817 if (width
> bits_available
)
3819 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3820 input_line_pointer
= hold
;
3821 exp
->X_add_number
= value
;
3826 hold
= ++input_line_pointer
;
3828 (void) expression (exp
);
3829 if (exp
->X_op
!= O_constant
)
3831 char cache
= *input_line_pointer
;
3833 *input_line_pointer
= '\0';
3834 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3835 *input_line_pointer
= cache
;
3836 demand_empty_rest_of_line ();
3838 } /* Too complex. */
3840 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3841 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3843 if ((bits_available
-= width
) == 0
3844 || is_it_end_of_statement ()
3845 || *input_line_pointer
!= ',')
3848 } /* All the bitfields we're gonna get. */
3850 hold
= ++input_line_pointer
;
3851 (void) expression (exp
);
3854 exp
->X_add_number
= value
;
3855 exp
->X_op
= O_constant
;
3856 exp
->X_unsigned
= 1;
3860 #endif /* BITFIELD_CONS_EXPRESSIONS */
3862 /* Handle an MRI style string expression. */
3866 parse_mri_cons (exp
, nbytes
)
3868 unsigned int nbytes
;
3870 if (*input_line_pointer
!= '\''
3871 && (input_line_pointer
[1] != '\''
3872 || (*input_line_pointer
!= 'A'
3873 && *input_line_pointer
!= 'E')))
3874 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3878 unsigned int result
= 0;
3880 /* An MRI style string. Cut into as many bytes as will fit into
3881 a nbyte chunk, left justify if necessary, and separate with
3882 commas so we can try again later. */
3883 if (*input_line_pointer
== 'A')
3884 ++input_line_pointer
;
3885 else if (*input_line_pointer
== 'E')
3887 as_bad (_("EBCDIC constants are not supported"));
3888 ++input_line_pointer
;
3891 input_line_pointer
++;
3892 for (scan
= 0; scan
< nbytes
; scan
++)
3894 if (*input_line_pointer
== '\'')
3896 if (input_line_pointer
[1] == '\'')
3898 input_line_pointer
++;
3903 result
= (result
<< 8) | (*input_line_pointer
++);
3907 while (scan
< nbytes
)
3913 /* Create correct expression. */
3914 exp
->X_op
= O_constant
;
3915 exp
->X_add_number
= result
;
3917 /* Fake it so that we can read the next char too. */
3918 if (input_line_pointer
[0] != '\'' ||
3919 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3921 input_line_pointer
-= 2;
3922 input_line_pointer
[0] = ',';
3923 input_line_pointer
[1] = '\'';
3926 input_line_pointer
++;
3929 #endif /* TC_M68K */
3931 #ifdef REPEAT_CONS_EXPRESSIONS
3933 /* Parse a repeat expression for cons. This is used by the MIPS
3934 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3935 object file COUNT times.
3937 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3940 parse_repeat_cons (exp
, nbytes
)
3942 unsigned int nbytes
;
3949 if (*input_line_pointer
!= ':')
3951 /* No repeat count. */
3955 ++input_line_pointer
;
3956 expression (&count
);
3957 if (count
.X_op
!= O_constant
3958 || count
.X_add_number
<= 0)
3960 as_warn (_("Unresolvable or nonpositive repeat count; using 1"));
3964 /* The cons function is going to output this expression once. So we
3965 output it count - 1 times. */
3966 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3967 emit_expr (exp
, nbytes
);
3970 #endif /* REPEAT_CONS_EXPRESSIONS */
3972 /* Parse a floating point number represented as a hex constant. This
3973 permits users to specify the exact bits they want in the floating
3977 hex_float (float_type
, bytes
)
4011 as_bad (_("Unknown floating type type '%c'"), float_type
);
4015 /* It would be nice if we could go through expression to parse the
4016 hex constant, but if we get a bignum it's a pain to sort it into
4017 the buffer correctly. */
4019 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4023 /* The MRI assembler accepts arbitrary underscores strewn about
4024 through the hex constant, so we ignore them as well. */
4025 if (*input_line_pointer
== '_')
4027 ++input_line_pointer
;
4033 as_warn (_("Floating point constant too large"));
4036 d
= hex_value (*input_line_pointer
) << 4;
4037 ++input_line_pointer
;
4038 while (*input_line_pointer
== '_')
4039 ++input_line_pointer
;
4040 if (hex_p (*input_line_pointer
))
4042 d
+= hex_value (*input_line_pointer
);
4043 ++input_line_pointer
;
4045 if (target_big_endian
)
4048 bytes
[length
- i
- 1] = d
;
4054 if (target_big_endian
)
4055 memset (bytes
+ i
, 0, length
- i
);
4057 memset (bytes
, 0, length
- i
);
4065 CONStruct some more frag chars of .floats .ffloats etc.
4066 Makes 0 or more new frags.
4067 If need_pass_2 == 1, no frags are emitted.
4068 This understands only floating literals, not expressions. Sorry.
4070 A floating constant is defined by atof_generic(), except it is preceded
4071 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4072 reading, I decided to be incompatible. This always tries to give you
4073 rounded bits to the precision of the pseudo-op. Former AS did premature
4074 truncatation, restored noisy bits instead of trailing 0s AND gave you
4075 a choice of 2 flavours of noise according to which of 2 floating-point
4076 scanners you directed AS to use.
4078 In: input_line_pointer->whitespace before, or '0' of flonum. */
4081 float_cons (float_type
)
4082 /* Clobbers input_line-pointer, checks end-of-line. */
4083 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4086 int length
; /* Number of chars in an object. */
4087 register char *err
; /* Error from scanning floating literal. */
4088 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4090 if (is_it_end_of_statement ())
4092 demand_empty_rest_of_line ();
4096 #ifdef md_flush_pending_output
4097 md_flush_pending_output ();
4102 /* input_line_pointer->1st char of a flonum (we hope!). */
4105 /* Skip any 0{letter} that may be present. Don't even check if the
4106 letter is legal. Someone may invent a "z" format and this routine
4107 has no use for such information. Lusers beware: you get
4108 diagnostics if your input is ill-conditioned. */
4109 if (input_line_pointer
[0] == '0'
4110 && isalpha ((unsigned char) input_line_pointer
[1]))
4111 input_line_pointer
+= 2;
4113 /* Accept :xxxx, where the x's are hex digits, for a floating
4114 point with the exact digits specified. */
4115 if (input_line_pointer
[0] == ':')
4117 ++input_line_pointer
;
4118 length
= hex_float (float_type
, temp
);
4121 ignore_rest_of_line ();
4127 err
= md_atof (float_type
, temp
, &length
);
4128 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4132 as_bad (_("Bad floating literal: %s"), err
);
4133 ignore_rest_of_line ();
4144 #ifdef REPEAT_CONS_EXPRESSIONS
4145 if (*input_line_pointer
== ':')
4147 expressionS count_exp
;
4149 ++input_line_pointer
;
4150 expression (&count_exp
);
4152 if (count_exp
.X_op
!= O_constant
4153 || count_exp
.X_add_number
<= 0)
4154 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4156 count
= count_exp
.X_add_number
;
4160 while (--count
>= 0)
4162 p
= frag_more (length
);
4163 memcpy (p
, temp
, (unsigned int) length
);
4168 while (*input_line_pointer
++ == ',');
4170 /* Put terminator back into stream. */
4171 --input_line_pointer
;
4172 demand_empty_rest_of_line ();
4175 /* Return the size of a LEB128 value. */
4178 sizeof_sleb128 (value
)
4181 register int size
= 0;
4182 register unsigned byte
;
4186 byte
= (value
& 0x7f);
4187 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4188 Fortunately, we can structure things so that the extra work reduces
4189 to a noop on systems that do things "properly". */
4190 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4193 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4194 || ((value
== -1) && ((byte
& 0x40) != 0))));
4200 sizeof_uleb128 (value
)
4203 register int size
= 0;
4204 register unsigned byte
;
4208 byte
= (value
& 0x7f);
4218 sizeof_leb128 (value
, sign
)
4223 return sizeof_sleb128 ((offsetT
) value
);
4225 return sizeof_uleb128 (value
);
4228 /* Output a LEB128 value. */
4231 output_sleb128 (p
, value
)
4235 register char *orig
= p
;
4240 unsigned byte
= (value
& 0x7f);
4242 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4243 Fortunately, we can structure things so that the extra work reduces
4244 to a noop on systems that do things "properly". */
4245 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4247 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4248 || ((value
== -1) && ((byte
& 0x40) != 0))));
4260 output_uleb128 (p
, value
)
4268 unsigned byte
= (value
& 0x7f);
4271 /* More bytes to follow. */
4282 output_leb128 (p
, value
, sign
)
4288 return output_sleb128 (p
, (offsetT
) value
);
4290 return output_uleb128 (p
, value
);
4293 /* Do the same for bignums. We combine sizeof with output here in that
4294 we don't output for NULL values of P. It isn't really as critical as
4295 for "normal" values that this be streamlined. */
4298 output_big_sleb128 (p
, bignum
, size
)
4300 LITTLENUM_TYPE
*bignum
;
4308 /* Strip leading sign extensions off the bignum. */
4309 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4314 if (loaded
< 7 && size
> 0)
4316 val
|= (*bignum
<< loaded
);
4317 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4328 if ((val
== 0 && (byte
& 0x40) == 0)
4329 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4330 && (byte
& 0x40) != 0))
4338 while (byte
& 0x80);
4344 output_big_uleb128 (p
, bignum
, size
)
4346 LITTLENUM_TYPE
*bignum
;
4354 /* Strip leading zeros off the bignum. */
4355 /* XXX: Is this needed? */
4356 while (size
> 0 && bignum
[size
- 1] == 0)
4361 if (loaded
< 7 && size
> 0)
4363 val
|= (*bignum
<< loaded
);
4364 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4373 if (size
> 0 || val
)
4380 while (byte
& 0x80);
4386 output_big_leb128 (p
, bignum
, size
, sign
)
4388 LITTLENUM_TYPE
*bignum
;
4392 return output_big_sleb128 (p
, bignum
, size
);
4394 return output_big_uleb128 (p
, bignum
, size
);
4397 /* Generate the appropriate fragments for a given expression to emit a
4401 emit_leb128_expr (exp
, sign
)
4405 operatorT op
= exp
->X_op
;
4408 if (op
== O_absent
|| op
== O_illegal
)
4410 as_warn (_("zero assumed for missing expression"));
4411 exp
->X_add_number
= 0;
4414 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4416 as_bad (_("floating point number invalid; zero assumed"));
4417 exp
->X_add_number
= 0;
4420 else if (op
== O_register
)
4422 as_warn (_("register value used as expression"));
4426 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
4427 a signal that this is leb128 data. It shouldn't optimize this away. */
4429 if (check_eh_frame (exp
, &nbytes
))
4432 /* Let the backend know that subsequent data may be byte aligned. */
4433 #ifdef md_cons_align
4437 if (op
== O_constant
)
4439 /* If we've got a constant, emit the thing directly right now. */
4441 valueT value
= exp
->X_add_number
;
4445 size
= sizeof_leb128 (value
, sign
);
4446 p
= frag_more (size
);
4447 output_leb128 (p
, value
, sign
);
4449 else if (op
== O_big
)
4451 /* O_big is a different sort of constant. */
4456 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4457 p
= frag_more (size
);
4458 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4462 /* Otherwise, we have to create a variable sized fragment and
4463 resolve things later. */
4465 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4466 make_expr_symbol (exp
), 0, (char *) NULL
);
4470 /* Parse the .sleb128 and .uleb128 pseudos. */
4481 emit_leb128_expr (&exp
, sign
);
4483 while (*input_line_pointer
++ == ',');
4485 input_line_pointer
--;
4486 demand_empty_rest_of_line ();
4489 /* We read 0 or more ',' separated, double-quoted strings.
4490 Caller should have checked need_pass_2 is FALSE because we don't
4494 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4495 /* Checks end-of-line. */
4496 register int append_zero
; /* 0: don't append '\0', else 1. */
4498 register unsigned int c
;
4501 #ifdef md_flush_pending_output
4502 md_flush_pending_output ();
4505 /* The following awkward logic is to parse ZERO or more strings,
4506 comma separated. Recall a string expression includes spaces
4507 before the opening '\"' and spaces after the closing '\"'.
4508 We fake a leading ',' if there is (supposed to be)
4509 a 1st, expression. We keep demanding expressions for each ','. */
4510 if (is_it_end_of_statement ())
4512 c
= 0; /* Skip loop. */
4513 ++input_line_pointer
; /* Compensate for end of loop. */
4517 c
= ','; /* Do loop. */
4519 while (c
== ',' || c
== '<' || c
== '"')
4522 switch (*input_line_pointer
)
4525 ++input_line_pointer
; /*->1st char of string. */
4526 start
= input_line_pointer
;
4527 while (is_a_char (c
= next_char_of_string ()))
4529 FRAG_APPEND_1_CHAR (c
);
4533 FRAG_APPEND_1_CHAR (0);
4535 know (input_line_pointer
[-1] == '\"');
4539 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4540 will emit .string with a filename in the .debug section
4541 after a sequence of constants. See the comment in
4542 emit_expr for the sequence. emit_expr will set
4543 dwarf_file_string to non-zero if this string might be a
4544 source file name. */
4545 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4546 dwarf_file_string
= 0;
4547 else if (dwarf_file_string
)
4549 c
= input_line_pointer
[-1];
4550 input_line_pointer
[-1] = '\0';
4551 listing_source_file (start
);
4552 input_line_pointer
[-1] = c
;
4559 input_line_pointer
++;
4560 c
= get_single_number ();
4561 FRAG_APPEND_1_CHAR (c
);
4562 if (*input_line_pointer
!= '>')
4564 as_bad (_("Expected <nn>"));
4566 input_line_pointer
++;
4569 input_line_pointer
++;
4573 c
= *input_line_pointer
;
4576 demand_empty_rest_of_line ();
4579 /* FIXME-SOMEDAY: I had trouble here on characters with the
4580 high bits set. We'll probably also have trouble with
4581 multibyte chars, wide chars, etc. Also be careful about
4582 returning values bigger than 1 byte. xoxorich. */
4585 next_char_of_string ()
4587 register unsigned int c
;
4589 c
= *input_line_pointer
++ & CHAR_MASK
;
4597 as_warn (_("Unterminated string: Newline inserted."));
4598 bump_line_counters ();
4601 #ifndef NO_STRING_ESCAPES
4603 switch (c
= *input_line_pointer
++)
4631 break; /* As itself. */
4647 for (i
= 0, number
= 0;
4648 isdigit (c
) && i
< 3;
4649 c
= *input_line_pointer
++, i
++)
4651 number
= number
* 8 + c
- '0';
4656 --input_line_pointer
;
4665 c
= *input_line_pointer
++;
4666 while (isxdigit (c
))
4669 number
= number
* 16 + c
- '0';
4670 else if (isupper (c
))
4671 number
= number
* 16 + c
- 'A' + 10;
4673 number
= number
* 16 + c
- 'a' + 10;
4674 c
= *input_line_pointer
++;
4677 --input_line_pointer
;
4682 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4683 as_warn (_("Unterminated string: Newline inserted."));
4685 bump_line_counters ();
4690 #ifdef ONLY_STANDARD_ESCAPES
4691 as_bad (_("Bad escaped character in string, '?' assumed"));
4693 #endif /* ONLY_STANDARD_ESCAPES */
4698 #endif /* ! defined (NO_STRING_ESCAPES) */
4707 get_segmented_expression (expP
)
4708 register expressionS
*expP
;
4710 register segT retval
;
4712 retval
= expression (expP
);
4713 if (expP
->X_op
== O_illegal
4714 || expP
->X_op
== O_absent
4715 || expP
->X_op
== O_big
)
4717 as_bad (_("expected address expression; zero assumed"));
4718 expP
->X_op
= O_constant
;
4719 expP
->X_add_number
= 0;
4720 retval
= absolute_section
;
4726 get_known_segmented_expression (expP
)
4727 register expressionS
*expP
;
4729 register segT retval
;
4731 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4733 /* There is no easy way to extract the undefined symbol from the
4735 if (expP
->X_add_symbol
!= NULL
4736 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4737 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4738 S_GET_NAME (expP
->X_add_symbol
));
4740 as_warn (_("some symbol undefined; zero assumed"));
4741 retval
= absolute_section
;
4742 expP
->X_op
= O_constant
;
4743 expP
->X_add_number
= 0;
4745 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4750 get_absolute_expression ()
4755 if (exp
.X_op
!= O_constant
)
4757 if (exp
.X_op
!= O_absent
)
4758 as_bad (_("bad or irreducible absolute expression; zero assumed"));
4759 exp
.X_add_number
= 0;
4761 return exp
.X_add_number
;
4764 char /* Return terminator. */
4765 get_absolute_expression_and_terminator (val_pointer
)
4766 long *val_pointer
; /* Return value of expression. */
4768 /* FIXME: val_pointer should probably be offsetT *. */
4769 *val_pointer
= (long) get_absolute_expression ();
4770 return (*input_line_pointer
++);
4773 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4774 Give a warning if that happens. */
4777 demand_copy_C_string (len_pointer
)
4782 if ((s
= demand_copy_string (len_pointer
)) != 0)
4786 for (len
= *len_pointer
; len
> 0; len
--)
4793 as_bad (_("This string may not contain \'\\0\'"));
4801 /* Demand string, but return a safe (=private) copy of the string.
4802 Return NULL if we can't read a string here. */
4805 demand_copy_string (lenP
)
4808 register unsigned int c
;
4814 if (*input_line_pointer
== '\"')
4816 input_line_pointer
++; /* Skip opening quote. */
4818 while (is_a_char (c
= next_char_of_string ()))
4820 obstack_1grow (¬es
, c
);
4823 /* JF this next line is so demand_copy_C_string will return a
4824 null terminated string. */
4825 obstack_1grow (¬es
, '\0');
4826 retval
= obstack_finish (¬es
);
4830 as_warn (_("Missing string"));
4832 ignore_rest_of_line ();
4838 /* In: Input_line_pointer->next character.
4840 Do: Skip input_line_pointer over all whitespace.
4842 Out: 1 if input_line_pointer->end-of-line. */
4845 is_it_end_of_statement ()
4848 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4852 equals (sym_name
, reassign
)
4856 register symbolS
*symbolP
; /* Symbol we are working with. */
4860 input_line_pointer
++;
4861 if (*input_line_pointer
== '=')
4862 input_line_pointer
++;
4864 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4865 input_line_pointer
++;
4868 stop
= mri_comment_field (&stopc
);
4870 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4872 /* Turn '. = mumble' into a .org mumble. */
4873 register segT segment
;
4876 segment
= get_known_segmented_expression (&exp
);
4878 do_org (segment
, &exp
, 0);
4885 symbolP
= symbol_find (sym_name
);
4886 local
= symbolP
== NULL
;
4888 #endif /* OBJ_COFF */
4889 symbolP
= symbol_find_or_make (sym_name
);
4890 /* Permit register names to be redefined. */
4892 && S_IS_DEFINED (symbolP
)
4893 && S_GET_SEGMENT (symbolP
) != reg_section
)
4894 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
4897 /* "set" symbols are local unless otherwise specified. */
4899 SF_SET_LOCAL (symbolP
);
4900 #endif /* OBJ_COFF */
4902 pseudo_set (symbolP
);
4907 /* Check garbage after the expression. */
4908 ignore_rest_of_line ();
4909 mri_comment_end (stop
, stopc
);
4913 /* .incbin -- include a file verbatim at the current location. */
4917 int x ATTRIBUTE_UNUSED
;
4928 #ifdef md_flush_pending_output
4929 md_flush_pending_output ();
4933 filename
= demand_copy_string (& len
);
4934 if (filename
== NULL
)
4939 /* Look for optional skip and count. */
4940 if (* input_line_pointer
== ',')
4942 ++ input_line_pointer
;
4943 skip
= get_absolute_expression ();
4947 if (* input_line_pointer
== ',')
4949 ++ input_line_pointer
;
4951 count
= get_absolute_expression ();
4953 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
4959 demand_empty_rest_of_line ();
4961 /* Try opening absolute path first, then try include dirs. */
4962 binfile
= fopen (filename
, FOPEN_RB
);
4963 if (binfile
== NULL
)
4967 path
= xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
4969 for (i
= 0; i
< include_dir_count
; i
++)
4971 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
4973 binfile
= fopen (path
, FOPEN_RB
);
4974 if (binfile
!= NULL
)
4978 if (binfile
== NULL
)
4979 as_bad (_("file not found: %s"), filename
);
4982 path
= xstrdup (filename
);
4988 register_dependency (path
);
4990 /* Compute the length of the file. */
4991 if (fseek (binfile
, 0, SEEK_END
) != 0)
4993 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
4996 file_len
= ftell (binfile
);
4998 /* If a count was not specified use the size of the file. */
5002 if (skip
+ count
> file_len
)
5004 as_bad (_("skip (%ld) + count (%ld) larger than file size (%ld)"),
5005 skip
, count
, file_len
);
5009 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
5011 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
5015 /* Allocate frag space and store file contents in it. */
5016 binfrag
= frag_more (count
);
5018 bytes
= fread (binfrag
, 1, count
, binfile
);
5020 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5021 path
, bytes
, count
);
5024 if (binfile
!= NULL
)
5030 /* .include -- include a file at this point. */
5034 int arg ATTRIBUTE_UNUSED
;
5043 filename
= demand_copy_string (&i
);
5044 if (filename
== NULL
)
5046 /* demand_copy_string has already printed an error and
5047 called ignore_rest_of_line. */
5055 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5056 && *input_line_pointer
!= ' '
5057 && *input_line_pointer
!= '\t')
5059 obstack_1grow (¬es
, *input_line_pointer
);
5060 ++input_line_pointer
;
5064 obstack_1grow (¬es
, '\0');
5065 filename
= obstack_finish (¬es
);
5066 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5067 ++input_line_pointer
;
5070 demand_empty_rest_of_line ();
5071 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
5073 for (i
= 0; i
< include_dir_count
; i
++)
5075 strcpy (path
, include_dirs
[i
]);
5077 strcat (path
, filename
);
5078 if (0 != (try = fopen (path
, FOPEN_RT
)))
5088 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5089 register_dependency (path
);
5090 input_scrub_insert_file (path
);
5094 add_include_dir (path
)
5099 if (include_dir_count
== 0)
5101 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5102 include_dirs
[0] = "."; /* Current dir. */
5103 include_dir_count
= 2;
5107 include_dir_count
++;
5109 (char **) realloc (include_dirs
,
5110 include_dir_count
* sizeof (*include_dirs
));
5113 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5116 if (i
> include_dir_maxlen
)
5117 include_dir_maxlen
= i
;
5120 /* Output debugging information to denote the source file. */
5123 generate_file_debug ()
5125 if (debug_type
== DEBUG_STABS
)
5126 stabs_generate_asm_file ();
5129 /* Output line number debugging information for the current source line. */
5132 generate_lineno_debug ()
5136 case DEBUG_UNSPECIFIED
:
5141 stabs_generate_asm_lineno ();
5144 ecoff_generate_asm_lineno ();
5147 /* ??? We could here indicate to dwarf2dbg.c that something
5148 has changed. However, since there is additional backend
5149 support that is required (calling dwarf2_emit_insn), we
5150 let dwarf2dbg.c call as_where on its own. */
5155 /* Output debugging information to mark a function entry point or end point.
5156 END_P is zero for .func, and non-zero for .endfunc. */
5162 do_s_func (end_p
, NULL
);
5165 /* Subroutine of s_func so targets can choose a different default prefix.
5166 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5169 do_s_func (end_p
, default_prefix
)
5171 const char *default_prefix
;
5173 /* Record the current function so that we can issue an error message for
5174 misplaced .func,.endfunc, and also so that .endfunc needs no
5176 static char *current_name
;
5177 static char *current_label
;
5181 if (current_name
== NULL
)
5183 as_bad (_("missing .func"));
5184 ignore_rest_of_line ();
5188 if (debug_type
== DEBUG_STABS
)
5189 stabs_generate_asm_endfunc (current_name
, current_label
);
5191 current_name
= current_label
= NULL
;
5196 char delim1
, delim2
;
5198 if (current_name
!= NULL
)
5200 as_bad (_(".endfunc missing for previous .func"));
5201 ignore_rest_of_line ();
5205 name
= input_line_pointer
;
5206 delim1
= get_symbol_end ();
5207 name
= xstrdup (name
);
5208 *input_line_pointer
= delim1
;
5210 if (*input_line_pointer
!= ',')
5213 asprintf (&label
, "%s%s", default_prefix
, name
);
5216 char leading_char
= 0;
5217 #ifdef BFD_ASSEMBLER
5218 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5220 /* Missing entry point, use function's name with the leading
5223 asprintf (&label
, "%c%s", leading_char
, name
);
5230 ++input_line_pointer
;
5232 label
= input_line_pointer
;
5233 delim2
= get_symbol_end ();
5234 label
= xstrdup (label
);
5235 *input_line_pointer
= delim2
;
5238 if (debug_type
== DEBUG_STABS
)
5239 stabs_generate_asm_func (name
, label
);
5241 current_name
= name
;
5242 current_label
= label
;
5245 demand_empty_rest_of_line ();
5250 int arg ATTRIBUTE_UNUSED
;
5252 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5254 ++input_line_pointer
;
5256 ++input_line_pointer
;
5260 read_print_statistics (file
)
5263 hash_print_statistics (file
, "pseudo-op table", po_hash
);
5266 /* Inserts the given line into the input stream.
5268 This call avoids macro/conditionals nesting checking, since the contents of
5269 the line are assumed to replace the contents of a line already scanned.
5271 An appropriate use of this function would be substition of input lines when
5272 called by md_start_line_hook(). The given line is assumed to already be
5273 properly scrubbed. */
5276 input_scrub_insert_line (line
)
5281 sb_add_string (&newline
, line
);
5282 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
5284 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
5287 /* Insert a file into the input stream; the path must resolve to an actual
5288 file; no include path searching or dependency registering is performed. */
5291 input_scrub_insert_file (path
)
5294 input_scrub_include_file (path
, input_line_pointer
);
5295 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);