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. */
39 #include "safe-ctype.h"
47 #ifndef TC_START_LABEL
48 #define TC_START_LABEL(x,y) (x==':')
51 /* Set by the object-format or the target. */
52 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
53 #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
58 else if ((SIZE) >= 4) \
60 else if ((SIZE) >= 2) \
68 char *input_line_pointer
; /*->next char of source file to parse. */
70 #if BITS_PER_CHAR != 8
71 /* The following table is indexed by[(char)] and will break if
72 a char does not have exactly 256 states (hopefully 0:255!)! */
77 /* The m88k unfortunately uses @ as a label beginner. */
82 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
87 /* The Delta 68k assembler permits % inside label names. */
92 /* The PowerPC Windows NT assemblers permits ? inside label names. */
97 /* The IA-64 assembler uses # as a suffix designating a symbol. We include
98 it in the symbol and strip it out in tc_canonicalize_symbol_name. */
103 /* The a29k assembler does not permits labels to start with $. */
108 /* The Delta 68k assembler permits ~ at start of label names. */
112 /* Used by is_... macros. our ctype[]. */
113 char lex_type
[256] = {
114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
116 0, 0, 0, LEX_HASH
, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
117 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
118 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
119 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
120 0, 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
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
122 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
123 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
124 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
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
133 Out: 1 if this character ends a line. */
134 char is_end_of_line
[256] = {
136 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, /* @abcdefghijklmno */
138 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* @abcdefghijklmno */
140 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
141 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* _!"#$%&'()*+,-./ */
142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
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, /* */
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 /* */
157 #ifdef IGNORE_OPCODE_CASE
158 char original_case_string
[128];
161 /* Functions private to this file. */
163 static char *buffer
; /* 1st char of each buffer of lines is here. */
164 static char *buffer_limit
; /*->1 + last char in buffer. */
166 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
167 in the tc-<CPU>.h file. See the "Porting GAS" section of the
169 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
171 static char *old_buffer
; /* JF a hack. */
172 static char *old_input
;
173 static char *old_limit
;
175 /* Variables for handling include file directory table. */
177 /* Table of pointers to directories to search for .include's. */
180 /* How many are in the table. */
181 int include_dir_count
;
183 /* Length of longest in table. */
184 int include_dir_maxlen
= 1;
186 #ifndef WORKING_DOT_WORD
187 struct broken_word
*broken_words
;
188 int new_broken_words
;
191 /* The current offset into the absolute section. We don't try to
192 build frags in the absolute section, since no data can be stored
193 there. We just keep track of the current offset. */
194 addressT abs_section_offset
;
196 /* If this line had an MRI style label, it is stored in this variable.
197 This is used by some of the MRI pseudo-ops. */
200 /* This global variable is used to support MRI common sections. We
201 translate such sections into a common symbol. This variable is
202 non-NULL when we are in an MRI common section. */
203 symbolS
*mri_common_symbol
;
205 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
206 need to align to an even byte boundary unless the next pseudo-op is
207 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
209 static int mri_pending_align
;
213 /* This variable is set to be non-zero if the next string we see might
214 be the name of the source file in DWARF debugging information. See
215 the comment in emit_expr for the format we look for. */
216 static int dwarf_file_string
;
220 static void cons_worker
PARAMS ((int, int));
221 static int scrub_from_string
PARAMS ((char *, int));
222 static void do_align
PARAMS ((int, char *, int, int));
223 static void s_align
PARAMS ((int, int));
224 static void s_lcomm_internal
PARAMS ((int, int));
225 static int hex_float
PARAMS ((int, char *));
226 static inline int sizeof_sleb128
PARAMS ((offsetT
));
227 static inline int sizeof_uleb128
PARAMS ((valueT
));
228 static inline int output_sleb128
PARAMS ((char *, offsetT
));
229 static inline int output_uleb128
PARAMS ((char *, valueT
));
230 static inline int output_big_sleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
231 static inline int output_big_uleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
232 static int output_big_leb128
PARAMS ((char *, LITTLENUM_TYPE
*, int, int));
233 static void do_org
PARAMS ((segT
, expressionS
*, int));
234 char *demand_copy_string
PARAMS ((int *lenP
));
235 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
236 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
237 static void pobegin
PARAMS ((void));
238 static int get_line_sb
PARAMS ((sb
*));
239 static void generate_file_debug
PARAMS ((void));
247 obj_read_begin_hook ();
249 /* Something close -- but not too close -- to a multiple of 1024.
250 The debugging malloc I'm using has 24 bytes of overhead. */
251 obstack_begin (¬es
, chunksize
);
252 obstack_begin (&cond_obstack
, chunksize
);
254 /* Use machine dependent syntax. */
255 for (p
= line_separator_chars
; *p
; p
++)
256 is_end_of_line
[(unsigned char) *p
] = 1;
257 /* Use more. FIXME-SOMEDAY. */
263 /* Set up pseudo-op tables. */
265 static struct hash_control
*po_hash
;
267 static const pseudo_typeS potable
[] = {
268 {"abort", s_abort
, 0},
269 {"align", s_align_ptwo
, 0},
270 {"ascii", stringer
, 0},
271 {"asciz", stringer
, 1},
272 {"balign", s_align_bytes
, 0},
273 {"balignw", s_align_bytes
, -2},
274 {"balignl", s_align_bytes
, -4},
278 {"common", s_mri_common
, 0},
279 {"common.s", s_mri_common
, 1},
283 {"dc.d", float_cons
, 'd'},
285 {"dc.s", float_cons
, 'f'},
287 {"dc.x", float_cons
, 'x'},
289 {"dcb.b", s_space
, 1},
290 {"dcb.d", s_float_space
, 'd'},
291 {"dcb.l", s_space
, 4},
292 {"dcb.s", s_float_space
, 'f'},
293 {"dcb.w", s_space
, 2},
294 {"dcb.x", s_float_space
, 'x'},
296 {"ds.b", s_space
, 1},
297 {"ds.d", s_space
, 8},
298 {"ds.l", s_space
, 4},
299 {"ds.p", s_space
, 12},
300 {"ds.s", s_space
, 4},
301 {"ds.w", s_space
, 2},
302 {"ds.x", s_space
, 12},
303 {"debug", s_ignore
, 0},
308 {"double", float_cons
, 'd'},
310 {"eject", listing_eject
, 0}, /* Formfeed listing. */
312 {"elsec", s_else
, 0},
313 {"elseif", s_elseif
, (int) O_ne
},
315 {"endc", s_endif
, 0},
316 {"endfunc", s_func
, 1},
317 {"endif", s_endif
, 0},
322 {"exitm", s_mexit
, 0},
324 {"extern", s_ignore
, 0}, /* We treat all undef as ext. */
325 {"appfile", s_app_file
, 1},
326 {"appline", s_app_line
, 0},
328 {"file", s_app_file
, 0},
330 {"float", float_cons
, 'f'},
331 {"format", s_ignore
, 0},
333 {"global", s_globl
, 0},
334 {"globl", s_globl
, 0},
336 {"if", s_if
, (int) O_ne
},
338 {"ifdef", s_ifdef
, 0},
339 {"ifeq", s_if
, (int) O_eq
},
340 {"ifeqs", s_ifeqs
, 0},
341 {"ifge", s_if
, (int) O_ge
},
342 {"ifgt", s_if
, (int) O_gt
},
343 {"ifle", s_if
, (int) O_le
},
344 {"iflt", s_if
, (int) O_lt
},
346 {"ifndef", s_ifdef
, 1},
347 {"ifne", s_if
, (int) O_ne
},
348 {"ifnes", s_ifeqs
, 1},
349 {"ifnotdef", s_ifdef
, 1},
350 {"incbin", s_incbin
, 0},
351 {"include", s_include
, 0},
357 {"lcomm", s_lcomm
, 0},
358 {"lflags", listing_flags
, 0}, /* Listing flags. */
359 {"linkonce", s_linkonce
, 0},
360 {"list", listing_list
, 1}, /* Turn listing on. */
361 {"llen", listing_psize
, 1},
364 {"macro", s_macro
, 0},
365 {"mexit", s_mexit
, 0},
367 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
368 {"name", s_ignore
, 0},
369 {"noformat", s_ignore
, 0},
370 {"nolist", listing_list
, 0}, /* Turn listing off. */
371 {"nopage", listing_nopage
, 0},
373 {"offset", s_struct
, 0},
375 {"p2align", s_align_ptwo
, 0},
376 {"p2alignw", s_align_ptwo
, -2},
377 {"p2alignl", s_align_ptwo
, -4},
378 {"page", listing_eject
, 0},
379 {"plen", listing_psize
, 0},
380 {"print", s_print
, 0},
381 {"psize", listing_psize
, 0}, /* Set paper size. */
382 {"purgem", s_purgem
, 0},
387 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
392 {"single", float_cons
, 'f'},
394 {"space", s_space
, 0},
395 {"skip", s_space
, 0},
396 {"sleb128", s_leb128
, 1},
397 {"spc", s_ignore
, 0},
398 {"stabd", s_stab
, 'd'},
399 {"stabn", s_stab
, 'n'},
400 {"stabs", s_stab
, 's'},
401 {"string", stringer
, 1},
402 {"struct", s_struct
, 0},
406 /* This is for gcc to use. It's only just been added (2/94), so gcc
407 won't be able to use it for a while -- probably a year or more.
408 But once this has been released, check with gcc maintainers
409 before deleting it or even changing the spelling. */
410 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
411 /* If we're folding case -- done for some targets, not necessarily
412 all -- the above string in an input file will be converted to
413 this one. Match it either way... */
414 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
416 {"title", listing_title
, 0}, /* Listing title. */
417 {"ttl", listing_title
, 0},
419 {"uleb128", s_leb128
, 0},
423 {"xdef", s_globl
, 0},
424 {"xref", s_ignore
, 0},
425 {"xstabs", s_xstab
, 's'},
427 {"zero", s_space
, 0},
428 {NULL
, NULL
, 0} /* End sentinel. */
431 static int pop_override_ok
= 0;
432 static const char *pop_table_name
;
436 const pseudo_typeS
*table
;
439 const pseudo_typeS
*pop
;
440 for (pop
= table
; pop
->poc_name
; pop
++)
442 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
443 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
444 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
449 #ifndef md_pop_insert
450 #define md_pop_insert() pop_insert(md_pseudo_table)
453 #ifndef obj_pop_insert
454 #define obj_pop_insert() pop_insert(obj_pseudo_table)
460 po_hash
= hash_new ();
462 /* Do the target-specific pseudo ops. */
463 pop_table_name
= "md";
466 /* Now object specific. Skip any that were in the target table. */
467 pop_table_name
= "obj";
471 /* Now portable ones. Skip any that we've seen already. */
472 pop_table_name
= "standard";
473 pop_insert (potable
);
476 #define HANDLE_CONDITIONAL_ASSEMBLY() \
477 if (ignore_input ()) \
479 while (!is_end_of_line[(unsigned char) *input_line_pointer++]) \
480 if (input_line_pointer == buffer_limit) \
485 /* This function is used when scrubbing the characters between #APP
488 static char *scrub_string
;
489 static char *scrub_string_end
;
492 scrub_from_string (buf
, buflen
)
498 copy
= scrub_string_end
- scrub_string
;
501 memcpy (buf
, scrub_string
, copy
);
502 scrub_string
+= copy
;
506 /* We read the file, putting things into a web that represents what we
507 have been reading. */
509 read_a_source_file (name
)
513 register char *s
; /* String of symbol, '\0' appended. */
521 buffer
= input_scrub_new_file (name
);
524 listing_newline (NULL
);
525 register_dependency (name
);
527 /* Generate debugging information before we've read anything in to denote
528 this file as the "main" source file and not a subordinate one
529 (e.g. N_SO vs N_SOL in stabs). */
530 generate_file_debug ();
532 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
533 { /* We have another line to parse. */
534 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
535 contin
: /* JF this goto is my fault I admit it.
536 Someone brave please re-write the whole
537 input section here? Pleeze??? */
538 while (input_line_pointer
< buffer_limit
)
540 /* We have more of this buffer to parse. */
542 /* We now have input_line_pointer->1st char of next line.
543 If input_line_pointer [-1] == '\n' then we just
544 scanned another line: so bump line counters. */
545 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
547 #ifdef md_start_line_hook
548 md_start_line_hook ();
550 if (input_line_pointer
[-1] == '\n')
551 bump_line_counters ();
555 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
557 /* Text at the start of a line must be a label, we
558 run down and stick a colon in. */
559 if (is_name_beginner (*input_line_pointer
))
561 char *line_start
= input_line_pointer
;
566 HANDLE_CONDITIONAL_ASSEMBLY ();
568 c
= get_symbol_end ();
570 /* In MRI mode, the EQU and MACRO pseudoops must
571 be handled specially. */
575 char *rest
= input_line_pointer
+ 1;
579 if (*rest
== ' ' || *rest
== '\t')
581 if ((strncasecmp (rest
, "EQU", 3) == 0
582 || strncasecmp (rest
, "SET", 3) == 0)
583 && (rest
[3] == ' ' || rest
[3] == '\t'))
585 input_line_pointer
= rest
+ 3;
587 strncasecmp (rest
, "SET", 3) == 0);
590 if (strncasecmp (rest
, "MACRO", 5) == 0
593 || is_end_of_line
[(unsigned char) rest
[5]]))
597 /* In MRI mode, we need to handle the MACRO
598 pseudo-op specially: we don't want to put the
599 symbol in the symbol table. */
601 #ifdef TC_START_LABEL_WITHOUT_COLON
602 && TC_START_LABEL_WITHOUT_COLON(c
,
606 line_label
= colon (line_start
);
608 line_label
= symbol_create (line_start
,
613 *input_line_pointer
= c
;
615 input_line_pointer
++;
620 /* We are at the begining of a line, or similar place.
621 We expect a well-formed assembler statement.
622 A "symbol-name:" is a statement.
624 Depending on what compiler is used, the order of these tests
625 may vary to catch most common case 1st.
626 Each test is independent of all other tests at the (top) level.
627 PLEASE make a compiler that doesn't use this assembler.
628 It is crufty to waste a compiler's time encoding things for this
629 assembler, which then wastes more time decoding it.
630 (And communicating via (linear) files is silly!
631 If you must pass stuff, please pass a tree!) */
632 if ((c
= *input_line_pointer
++) == '\t'
636 c
= *input_line_pointer
++;
638 know (c
!= ' '); /* No further leading whitespace. */
641 /* If listing is on, and we are expanding a macro, then give
642 the listing code the contents of the expanded line. */
645 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
650 /* Find the end of the current expanded macro line. */
651 for (s
= input_line_pointer
- 1; *s
; ++s
)
652 if (is_end_of_line
[(unsigned char) *s
])
655 /* Copy it for safe keeping. Also give an indication of
656 how much macro nesting is involved at this point. */
657 len
= s
- (input_line_pointer
- 1);
658 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
659 memset (copy
, '>', macro_nest
);
660 copy
[macro_nest
] = ' ';
661 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
- 1, len
);
662 copy
[macro_nest
+ 1 + len
] = '\0';
664 /* Install the line with the listing facility. */
665 listing_newline (copy
);
668 listing_newline (NULL
);
671 /* C is the 1st significant character.
672 Input_line_pointer points after that character. */
673 if (is_name_beginner (c
))
675 /* Want user-defined label or pseudo/opcode. */
676 HANDLE_CONDITIONAL_ASSEMBLY ();
678 s
= --input_line_pointer
;
679 c
= get_symbol_end (); /* name's delimiter. */
681 /* C is character after symbol.
682 That character's place in the input line is now '\0'.
683 S points to the beginning of the symbol.
684 [In case of pseudo-op, s->'.'.]
685 Input_line_pointer->'\0' where c was. */
686 if (TC_START_LABEL (c
, input_line_pointer
))
690 char *rest
= input_line_pointer
+ 1;
692 /* In MRI mode, \tsym: set 0 is permitted. */
696 if (*rest
== ' ' || *rest
== '\t')
699 if ((strncasecmp (rest
, "EQU", 3) == 0
700 || strncasecmp (rest
, "SET", 3) == 0)
701 && (rest
[3] == ' ' || rest
[3] == '\t'))
703 input_line_pointer
= rest
+ 3;
709 line_label
= colon (s
); /* User-defined label. */
710 /* Put ':' back for error messages' sake. */
711 *input_line_pointer
++ = ':';
712 /* Input_line_pointer->after ':'. */
716 || ((c
== ' ' || c
== '\t')
717 && input_line_pointer
[1] == '='
718 #ifdef TC_EQUAL_IN_INSN
719 && !TC_EQUAL_IN_INSN (c
, input_line_pointer
)
724 demand_empty_rest_of_line ();
728 /* Expect pseudo-op or machine instruction. */
731 #ifdef IGNORE_OPCODE_CASE
735 strncpy (original_case_string
, s2
, sizeof (original_case_string
));
736 original_case_string
[sizeof (original_case_string
) - 1] = 0;
745 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
747 /* The MRI assembler and the m88k use pseudo-ops
749 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
750 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
755 || (!flag_m68k_mri
&& *s
== '.'))
759 WARNING: c has next char, which may be end-of-line.
760 We lookup the pseudo-op table with s+1 because we
761 already know that the pseudo-op begins with a '.'. */
764 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
766 /* In MRI mode, we may need to insert an
767 automatic alignment directive. What a hack
769 if (mri_pending_align
771 || !((pop
->poc_handler
== cons
772 && pop
->poc_val
== 1)
773 || (pop
->poc_handler
== s_space
774 && pop
->poc_val
== 1)
775 #ifdef tc_conditional_pseudoop
776 || tc_conditional_pseudoop (pop
)
778 || pop
->poc_handler
== s_if
779 || pop
->poc_handler
== s_ifdef
780 || pop
->poc_handler
== s_ifc
781 || pop
->poc_handler
== s_ifeqs
782 || pop
->poc_handler
== s_else
783 || pop
->poc_handler
== s_endif
784 || pop
->poc_handler
== s_globl
785 || pop
->poc_handler
== s_ignore
)))
787 do_align (1, (char *) NULL
, 0, 0);
788 mri_pending_align
= 0;
790 if (line_label
!= NULL
)
792 symbol_set_frag (line_label
, frag_now
);
793 S_SET_VALUE (line_label
, frag_now_fix ());
797 /* Print the error msg now, while we still can. */
800 as_bad (_("unknown pseudo-op: `%s'"), s
);
801 *input_line_pointer
= c
;
806 /* Put it back for error messages etc. */
807 *input_line_pointer
= c
;
808 /* The following skip of whitespace is compulsory.
809 A well shaped space is sometimes all that separates
810 keyword from operands. */
811 if (c
== ' ' || c
== '\t')
812 input_line_pointer
++;
814 /* Input_line is restored.
815 Input_line_pointer->1st non-blank char
816 after pseudo-operation. */
817 (*pop
->poc_handler
) (pop
->poc_val
);
819 /* If that was .end, just get out now. */
820 if (pop
->poc_handler
== s_end
)
826 #ifdef QUOTES_IN_INSN
830 /* WARNING: c has char, which may be end-of-line. */
831 /* Also: input_line_pointer->`\0` where c was. */
832 *input_line_pointer
= c
;
833 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
835 #ifdef TC_EOL_IN_INSN
836 || TC_EOL_IN_INSN (input_line_pointer
)
840 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
842 #ifdef QUOTES_IN_INSN
845 else if (*input_line_pointer
== '"')
847 else if (*input_line_pointer
== '\\')
850 input_line_pointer
++;
853 c
= *input_line_pointer
;
854 *input_line_pointer
= '\0';
856 generate_lineno_debug ();
864 if (check_macro (s
, &out
, '\0', &err
, ¯o
))
868 *input_line_pointer
++ = c
;
869 input_scrub_include_sb (&out
,
870 input_line_pointer
, 1);
873 input_scrub_next_buffer (&input_line_pointer
);
875 md_macro_info (macro
);
881 if (mri_pending_align
)
883 do_align (1, (char *) NULL
, 0, 0);
884 mri_pending_align
= 0;
885 if (line_label
!= NULL
)
887 symbol_set_frag (line_label
, frag_now
);
888 S_SET_VALUE (line_label
, frag_now_fix ());
892 md_assemble (s
); /* Assemble 1 instruction. */
894 *input_line_pointer
++ = c
;
896 /* We resume loop AFTER the end-of-line from
903 /* Empty statement? */
904 if (is_end_of_line
[(unsigned char) c
])
907 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
) && ISDIGIT (c
))
909 /* local label ("4:") */
910 char *backup
= input_line_pointer
;
912 HANDLE_CONDITIONAL_ASSEMBLY ();
916 /* Read the whole number. */
917 while (ISDIGIT (*input_line_pointer
))
919 temp
= (temp
* 10) + *input_line_pointer
- '0';
920 ++input_line_pointer
;
923 if (LOCAL_LABELS_DOLLAR
924 && *input_line_pointer
== '$'
925 && *(input_line_pointer
+ 1) == ':')
927 input_line_pointer
+= 2;
929 if (dollar_label_defined (temp
))
931 as_fatal (_("label \"%d$\" redefined"), temp
);
934 define_dollar_label (temp
);
935 colon (dollar_label_name (temp
, 0));
940 && *input_line_pointer
++ == ':')
942 fb_label_instance_inc (temp
);
943 colon (fb_label_name (temp
, 0));
947 input_line_pointer
= backup
;
948 } /* local label ("4:") */
950 if (c
&& strchr (line_comment_chars
, c
))
951 { /* Its a comment. Better say APP or NO_APP. */
955 unsigned int new_length
;
958 bump_line_counters ();
959 s
= input_line_pointer
;
960 if (strncmp (s
, "APP\n", 4))
961 continue; /* We ignore it */
964 ends
= strstr (s
, "#NO_APP\n");
968 unsigned int tmp_len
;
971 /* The end of the #APP wasn't in this buffer. We
972 keep reading in buffers until we find the #NO_APP
973 that goes with this #APP There is one. The specs
975 tmp_len
= buffer_limit
- s
;
976 tmp_buf
= xmalloc (tmp_len
+ 1);
977 memcpy (tmp_buf
, s
, tmp_len
);
980 new_tmp
= input_scrub_next_buffer (&buffer
);
984 buffer_limit
= new_tmp
;
985 input_line_pointer
= buffer
;
986 ends
= strstr (buffer
, "#NO_APP\n");
990 num
= buffer_limit
- buffer
;
992 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
993 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
998 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1006 input_line_pointer
= ends
+ 8;
1010 scrub_string_end
= ends
;
1012 new_length
= ends
- s
;
1013 new_buf
= (char *) xmalloc (new_length
);
1020 space
= (new_buf
+ new_length
) - new_tmp
;
1021 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1029 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1030 new_tmp
= new_buf
+ new_length
;
1036 old_buffer
= buffer
;
1037 old_input
= input_line_pointer
;
1038 old_limit
= buffer_limit
;
1040 input_line_pointer
= new_buf
;
1041 buffer_limit
= new_tmp
;
1046 HANDLE_CONDITIONAL_ASSEMBLY ();
1048 #ifdef tc_unrecognized_line
1049 if (tc_unrecognized_line (c
))
1052 input_line_pointer
--;
1053 /* Report unknown char as ignored. */
1054 ignore_rest_of_line ();
1057 #ifdef md_after_pass_hook
1058 md_after_pass_hook ();
1064 bump_line_counters ();
1067 buffer
= old_buffer
;
1068 input_line_pointer
= old_input
;
1069 buffer_limit
= old_limit
;
1081 /* Close the input file. */
1082 input_scrub_close ();
1083 #ifdef WARN_COMMENTS
1085 if (warn_comment
&& found_comment
)
1086 as_warn_where (found_comment_file
, found_comment
,
1087 "first comment found here");
1092 /* For most MRI pseudo-ops, the line actually ends at the first
1093 nonquoted space. This function looks for that point, stuffs a null
1094 in, and sets *STOPCP to the character that used to be there, and
1095 returns the location.
1097 Until I hear otherwise, I am going to assume that this is only true
1098 for the m68k MRI assembler. */
1101 mri_comment_field (stopcp
)
1108 know (flag_m68k_mri
);
1110 for (s
= input_line_pointer
;
1111 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1119 for (s
= input_line_pointer
;
1120 !is_end_of_line
[(unsigned char) *s
];
1130 /* Skip to the end of an MRI comment field. */
1133 mri_comment_end (stop
, stopc
)
1139 input_line_pointer
= stop
;
1141 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1142 ++input_line_pointer
;
1147 int ignore ATTRIBUTE_UNUSED
;
1149 as_fatal (_(".abort detected. Abandoning ship."));
1152 /* Guts of .align directive. N is the power of two to which to align.
1153 FILL may be NULL, or it may point to the bytes of the fill pattern.
1154 LEN is the length of whatever FILL points to, if anything. MAX is
1155 the maximum number of characters to skip when doing the alignment,
1156 or 0 if there is no maximum. */
1159 do_align (n
, fill
, len
, max
)
1165 if (now_seg
== absolute_section
)
1169 if (*fill
++ != '\0')
1171 as_warn (_("ignoring fill value in absolute section"));
1179 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1182 /* Only make a frag if we HAVE to... */
1183 if (n
!= 0 && !need_pass_2
)
1187 if (subseg_text_p (now_seg
))
1188 frag_align_code (n
, max
);
1190 frag_align (n
, 0, max
);
1193 frag_align (n
, *fill
, max
);
1195 frag_align_pattern (n
, fill
, len
, max
);
1199 just_record_alignment
:
1202 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1205 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1206 (in bytes). A negative ARG is the negative of the length of the
1207 fill pattern. BYTES_P is non-zero if the alignment value should be
1208 interpreted as the byte boundary, rather than the power of 2. */
1211 s_align (arg
, bytes_p
)
1215 register unsigned int align
;
1223 stop
= mri_comment_field (&stopc
);
1225 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1230 align
= arg
; /* Default value from pseudo-op table. */
1234 align
= get_absolute_expression ();
1240 /* Convert to a power of 2. */
1245 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1248 as_bad (_("alignment not a power of 2"));
1257 as_warn (_("alignment too large: %u assumed"), align
);
1260 if (*input_line_pointer
!= ',')
1267 ++input_line_pointer
;
1268 if (*input_line_pointer
== ',')
1272 fill
= get_absolute_expression ();
1277 if (*input_line_pointer
!= ',')
1281 ++input_line_pointer
;
1282 max
= get_absolute_expression ();
1289 as_warn (_("expected fill pattern missing"));
1290 do_align (align
, (char *) NULL
, 0, max
);
1305 do_align (align
, &fill_char
, fill_len
, max
);
1311 if ((size_t) fill_len
> sizeof ab
)
1313 md_number_to_chars (ab
, fill
, fill_len
);
1314 do_align (align
, ab
, fill_len
, max
);
1318 demand_empty_rest_of_line ();
1321 mri_comment_end (stop
, stopc
);
1324 /* Handle the .align pseudo-op on machines where ".align 4" means
1325 align to a 4 byte boundary. */
1334 /* Handle the .align pseudo-op on machines where ".align 4" means align
1335 to a 2**4 boundary. */
1346 int ignore ATTRIBUTE_UNUSED
;
1348 register char *name
;
1352 register symbolS
*symbolP
;
1357 stop
= mri_comment_field (&stopc
);
1359 name
= input_line_pointer
;
1360 c
= get_symbol_end ();
1361 /* Just after name is now '\0'. */
1362 p
= input_line_pointer
;
1367 as_bad (_("expected symbol name"));
1368 discard_rest_of_line ();
1374 if (*input_line_pointer
!= ',')
1377 as_bad (_("expected comma after \"%s\""), name
);
1379 ignore_rest_of_line ();
1381 mri_comment_end (stop
, stopc
);
1385 input_line_pointer
++; /* skip ',' */
1387 if ((temp
= get_absolute_expression ()) < 0)
1389 as_warn (_(".COMMon length (%ld) < 0 ignored"), (long) temp
);
1390 ignore_rest_of_line ();
1392 mri_comment_end (stop
, stopc
);
1397 symbolP
= symbol_find_or_make (name
);
1400 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1402 as_bad (_("symbol `%s' is already defined"),
1403 S_GET_NAME (symbolP
));
1404 ignore_rest_of_line ();
1406 mri_comment_end (stop
, stopc
);
1410 if (S_GET_VALUE (symbolP
))
1412 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1413 as_bad (_("length of .comm \"%s\" is already %ld; not changing to %ld"),
1414 S_GET_NAME (symbolP
),
1415 (long) S_GET_VALUE (symbolP
),
1420 S_SET_VALUE (symbolP
, (valueT
) temp
);
1421 S_SET_EXTERNAL (symbolP
);
1425 extern int flag_one
;
1426 if (!temp
|| !flag_one
)
1427 S_GET_OTHER(symbolP
) = const_flag
;
1429 #endif /* not OBJ_VMS */
1430 know (symbolP
->sy_frag
== &zero_address_frag
);
1432 demand_empty_rest_of_line ();
1435 mri_comment_end (stop
, stopc
);
1438 /* The MRI COMMON pseudo-op. We handle this by creating a common
1439 symbol with the appropriate name. We make s_space do the right
1440 thing by increasing the size. */
1443 s_mri_common (small
)
1444 int small ATTRIBUTE_UNUSED
;
1460 stop
= mri_comment_field (&stopc
);
1464 name
= input_line_pointer
;
1465 if (!ISDIGIT (*name
))
1466 c
= get_symbol_end ();
1471 ++input_line_pointer
;
1473 while (ISDIGIT (*input_line_pointer
));
1475 c
= *input_line_pointer
;
1476 *input_line_pointer
= '\0';
1478 if (line_label
!= NULL
)
1480 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1481 + (input_line_pointer
- name
)
1483 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1488 sym
= symbol_find_or_make (name
);
1489 *input_line_pointer
= c
;
1493 if (*input_line_pointer
!= ',')
1497 ++input_line_pointer
;
1498 align
= get_absolute_expression ();
1501 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1503 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1504 ignore_rest_of_line ();
1505 mri_comment_end (stop
, stopc
);
1509 S_SET_EXTERNAL (sym
);
1510 mri_common_symbol
= sym
;
1514 S_SET_ALIGN (sym
, align
);
1517 if (line_label
!= NULL
)
1520 exp
.X_op
= O_symbol
;
1521 exp
.X_add_symbol
= sym
;
1522 exp
.X_add_number
= 0;
1523 symbol_set_value_expression (line_label
, &exp
);
1524 symbol_set_frag (line_label
, &zero_address_frag
);
1525 S_SET_SEGMENT (line_label
, expr_section
);
1528 /* FIXME: We just ignore the small argument, which distinguishes
1529 COMMON and COMMON.S. I don't know what we can do about it. */
1531 /* Ignore the type and hptype. */
1532 if (*input_line_pointer
== ',')
1533 input_line_pointer
+= 2;
1534 if (*input_line_pointer
== ',')
1535 input_line_pointer
+= 2;
1537 demand_empty_rest_of_line ();
1539 mri_comment_end (stop
, stopc
);
1544 int ignore ATTRIBUTE_UNUSED
;
1549 temp
= get_absolute_expression ();
1550 if (flag_readonly_data_in_text
)
1552 section
= text_section
;
1556 section
= data_section
;
1558 subseg_set (section
, (subsegT
) temp
);
1563 demand_empty_rest_of_line ();
1566 /* Handle the .appfile pseudo-op. This is automatically generated by
1567 do_scrub_chars when a preprocessor # line comment is seen with a
1568 file name. This default definition may be overridden by the object
1569 or CPU specific pseudo-ops. This function is also the default
1570 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1574 s_app_file (appfile
)
1580 /* Some assemblers tolerate immediately following '"'. */
1581 if ((s
= demand_copy_string (&length
)) != 0)
1583 /* If this is a fake .appfile, a fake newline was inserted into
1584 the buffer. Passing -2 to new_logical_line tells it to
1587 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1589 /* In MRI mode, the preprocessor may have inserted an extraneous
1592 && *input_line_pointer
== '\''
1593 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1594 ++input_line_pointer
;
1596 demand_empty_rest_of_line ();
1601 listing_source_file (s
);
1603 register_dependency (s
);
1611 /* Handle the .appline pseudo-op. This is automatically generated by
1612 do_scrub_chars when a preprocessor # line comment is seen. This
1613 default definition may be overridden by the object or CPU specific
1618 int ignore ATTRIBUTE_UNUSED
;
1622 /* The given number is that of the next line. */
1623 l
= get_absolute_expression () - 1;
1625 /* Some of the back ends can't deal with non-positive line numbers.
1626 Besides, it's silly. */
1627 as_warn (_("line numbers must be positive; line number %d rejected"),
1631 new_logical_line ((char *) NULL
, l
);
1634 listing_source_line (l
);
1637 demand_empty_rest_of_line ();
1640 /* Handle the .end pseudo-op. Actually, the real work is done in
1641 read_a_source_file. */
1645 int ignore ATTRIBUTE_UNUSED
;
1649 /* The MRI assembler permits the start symbol to follow .end,
1650 but we don't support that. */
1652 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1653 && *input_line_pointer
!= '*'
1654 && *input_line_pointer
!= '!')
1655 as_warn (_("start address not supported"));
1659 /* Handle the .err pseudo-op. */
1663 int ignore ATTRIBUTE_UNUSED
;
1665 as_bad (_(".err encountered"));
1666 demand_empty_rest_of_line ();
1669 /* Handle the MRI fail pseudo-op. */
1673 int ignore ATTRIBUTE_UNUSED
;
1680 stop
= mri_comment_field (&stopc
);
1682 temp
= get_absolute_expression ();
1684 as_warn (_(".fail %ld encountered"), (long) temp
);
1686 as_bad (_(".fail %ld encountered"), (long) temp
);
1688 demand_empty_rest_of_line ();
1691 mri_comment_end (stop
, stopc
);
1696 int ignore ATTRIBUTE_UNUSED
;
1698 expressionS rep_exp
;
1700 register long fill
= 0;
1703 #ifdef md_flush_pending_output
1704 md_flush_pending_output ();
1707 get_known_segmented_expression (&rep_exp
);
1708 if (*input_line_pointer
== ',')
1710 input_line_pointer
++;
1711 size
= get_absolute_expression ();
1712 if (*input_line_pointer
== ',')
1714 input_line_pointer
++;
1715 fill
= get_absolute_expression ();
1719 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1720 #define BSD_FILL_SIZE_CROCK_8 (8)
1721 if (size
> BSD_FILL_SIZE_CROCK_8
)
1723 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
1724 size
= BSD_FILL_SIZE_CROCK_8
;
1728 as_warn (_("size negative; .fill ignored"));
1731 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1733 if (rep_exp
.X_add_number
< 0)
1734 as_warn (_("repeat < 0; .fill ignored"));
1738 if (size
&& !need_pass_2
)
1740 if (rep_exp
.X_op
== O_constant
)
1742 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1743 (relax_substateT
) 0, (symbolS
*) 0,
1744 (offsetT
) rep_exp
.X_add_number
,
1749 /* We don't have a constant repeat count, so we can't use
1750 rs_fill. We can get the same results out of rs_space,
1751 but its argument is in bytes, so we must multiply the
1752 repeat count by size. */
1755 rep_sym
= make_expr_symbol (&rep_exp
);
1758 expressionS size_exp
;
1759 size_exp
.X_op
= O_constant
;
1760 size_exp
.X_add_number
= size
;
1762 rep_exp
.X_op
= O_multiply
;
1763 rep_exp
.X_add_symbol
= rep_sym
;
1764 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1765 rep_exp
.X_add_number
= 0;
1766 rep_sym
= make_expr_symbol (&rep_exp
);
1769 p
= frag_var (rs_space
, (int) size
, (int) size
,
1770 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1773 memset (p
, 0, (unsigned int) size
);
1775 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1776 flavoured AS. The following bizarre behaviour is to be
1777 compatible with above. I guess they tried to take up to 8
1778 bytes from a 4-byte expression and they forgot to sign
1780 #define BSD_FILL_SIZE_CROCK_4 (4)
1781 md_number_to_chars (p
, (valueT
) fill
,
1782 (size
> BSD_FILL_SIZE_CROCK_4
1783 ? BSD_FILL_SIZE_CROCK_4
1785 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1786 but emits no error message because it seems a legal thing to do.
1787 It is a degenerate case of .fill but could be emitted by a
1790 demand_empty_rest_of_line ();
1795 int ignore ATTRIBUTE_UNUSED
;
1804 stop
= mri_comment_field (&stopc
);
1808 name
= input_line_pointer
;
1809 c
= get_symbol_end ();
1810 symbolP
= symbol_find_or_make (name
);
1811 S_SET_EXTERNAL (symbolP
);
1813 *input_line_pointer
= c
;
1815 c
= *input_line_pointer
;
1818 input_line_pointer
++;
1820 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1826 demand_empty_rest_of_line ();
1829 mri_comment_end (stop
, stopc
);
1832 /* Handle the MRI IRP and IRPC pseudo-ops. */
1844 as_where (&file
, &line
);
1847 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1848 sb_add_char (&s
, *input_line_pointer
++);
1852 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1854 as_bad_where (file
, line
, "%s", err
);
1858 input_scrub_include_sb (&out
, input_line_pointer
, 1);
1860 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1863 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1864 the section to only be linked once. However, this is not supported
1865 by most object file formats. This takes an optional argument,
1866 which is what to do about duplicates. */
1870 int ignore ATTRIBUTE_UNUSED
;
1872 enum linkonce_type type
;
1876 type
= LINKONCE_DISCARD
;
1878 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1883 s
= input_line_pointer
;
1884 c
= get_symbol_end ();
1885 if (strcasecmp (s
, "discard") == 0)
1886 type
= LINKONCE_DISCARD
;
1887 else if (strcasecmp (s
, "one_only") == 0)
1888 type
= LINKONCE_ONE_ONLY
;
1889 else if (strcasecmp (s
, "same_size") == 0)
1890 type
= LINKONCE_SAME_SIZE
;
1891 else if (strcasecmp (s
, "same_contents") == 0)
1892 type
= LINKONCE_SAME_CONTENTS
;
1894 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1896 *input_line_pointer
= c
;
1899 #ifdef obj_handle_link_once
1900 obj_handle_link_once (type
);
1901 #else /* ! defined (obj_handle_link_once) */
1902 #ifdef BFD_ASSEMBLER
1906 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1907 as_warn (_(".linkonce is not supported for this object file format"));
1909 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1910 flags
|= SEC_LINK_ONCE
;
1915 case LINKONCE_DISCARD
:
1916 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1918 case LINKONCE_ONE_ONLY
:
1919 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1921 case LINKONCE_SAME_SIZE
:
1922 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1924 case LINKONCE_SAME_CONTENTS
:
1925 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1928 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1929 as_bad (_("bfd_set_section_flags: %s"),
1930 bfd_errmsg (bfd_get_error ()));
1932 #else /* ! defined (BFD_ASSEMBLER) */
1933 as_warn (_(".linkonce is not supported for this object file format"));
1934 #endif /* ! defined (BFD_ASSEMBLER) */
1935 #endif /* ! defined (obj_handle_link_once) */
1937 demand_empty_rest_of_line ();
1941 s_lcomm_internal (needs_align
, bytes_p
)
1942 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1943 (alignment); 0 if it was an ".lcomm" (2 args only). */
1945 /* 1 if the alignment value should be interpreted as the byte boundary,
1946 rather than the power of 2. */
1949 register char *name
;
1953 register symbolS
*symbolP
;
1954 segT current_seg
= now_seg
;
1955 subsegT current_subseg
= now_subseg
;
1956 const int max_alignment
= 15;
1958 segT bss_seg
= bss_section
;
1960 name
= input_line_pointer
;
1961 c
= get_symbol_end ();
1962 p
= input_line_pointer
;
1967 as_bad (_("expected symbol name"));
1968 discard_rest_of_line ();
1974 /* Accept an optional comma after the name. The comma used to be
1975 required, but Irix 5 cc does not generate it. */
1976 if (*input_line_pointer
== ',')
1978 ++input_line_pointer
;
1982 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1984 as_bad (_("missing size expression"));
1988 if ((temp
= get_absolute_expression ()) < 0)
1990 as_warn (_("BSS length (%d) < 0 ignored"), temp
);
1991 ignore_rest_of_line ();
1995 #if defined (TC_MIPS) || defined (TC_ALPHA)
1996 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1997 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1999 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
2000 if ((unsigned) temp
<= bfd_get_gp_size (stdoutput
))
2002 bss_seg
= subseg_new (".sbss", 1);
2003 seg_info (bss_seg
)->bss
= 1;
2004 #ifdef BFD_ASSEMBLER
2005 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
2006 as_warn (_("error setting flags for \".sbss\": %s"),
2007 bfd_errmsg (bfd_get_error ()));
2015 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
2017 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
2019 record_alignment (bss_seg
, align
);
2027 if (*input_line_pointer
!= ',')
2029 as_bad (_("expected comma after size"));
2030 ignore_rest_of_line ();
2034 input_line_pointer
++;
2037 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2039 as_bad (_("missing alignment"));
2043 align
= get_absolute_expression ();
2047 /* Convert to a power of 2. */
2052 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2055 as_bad (_("alignment not a power of 2"));
2060 if (align
> max_alignment
)
2062 align
= max_alignment
;
2063 as_warn (_("alignment too large; %d assumed"), align
);
2068 as_warn (_("alignment negative; 0 assumed"));
2071 record_alignment (bss_seg
, align
);
2075 /* Assume some objects may require alignment on some systems. */
2076 #if defined (TC_ALPHA) && ! defined (VMS)
2079 align
= ffs (temp
) - 1;
2080 if (temp
% (1 << align
))
2087 symbolP
= symbol_find_or_make (name
);
2091 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2092 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2093 #ifdef BFD_ASSEMBLER
2094 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2095 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2097 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2100 (S_GET_SEGMENT (symbolP
) == bss_seg
2101 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2105 subseg_set (bss_seg
, 1);
2108 frag_align (align
, 0, 0);
2110 /* Detach from old frag. */
2111 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2112 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2114 symbol_set_frag (symbolP
, frag_now
);
2115 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2116 (offsetT
) temp
, (char *) 0);
2119 S_SET_SEGMENT (symbolP
, bss_seg
);
2122 /* The symbol may already have been created with a preceding
2123 ".globl" directive -- be careful not to step on storage class
2124 in that case. Otherwise, set it to static. */
2125 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2127 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2129 #endif /* OBJ_COFF */
2132 S_SET_SIZE (symbolP
, temp
);
2136 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2138 subseg_set (current_seg
, current_subseg
);
2140 demand_empty_rest_of_line ();
2144 s_lcomm (needs_align
)
2147 s_lcomm_internal (needs_align
, 0);
2151 s_lcomm_bytes (needs_align
)
2154 s_lcomm_internal (needs_align
, 1);
2159 int ignore ATTRIBUTE_UNUSED
;
2161 register char *name
;
2165 register symbolS
*symbolP
;
2167 /* We permit ANY defined expression: BSD4.2 demands constants. */
2168 name
= input_line_pointer
;
2169 c
= get_symbol_end ();
2170 p
= input_line_pointer
;
2175 as_bad (_("expected symbol name"));
2176 discard_rest_of_line ();
2182 if (*input_line_pointer
!= ',')
2185 as_bad (_("expected comma after \"%s\""), name
);
2187 ignore_rest_of_line ();
2191 input_line_pointer
++;
2194 if (exp
.X_op
!= O_constant
2195 && exp
.X_op
!= O_register
)
2197 as_bad (_("bad expression"));
2198 ignore_rest_of_line ();
2203 symbolP
= symbol_find_or_make (name
);
2205 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2206 symbolP->sy_desc == 0) out of this test because coff doesn't have
2207 those fields, and I can't see when they'd ever be tripped. I
2208 don't think I understand why they were here so I may have
2209 introduced a bug. As recently as 1.37 didn't have this test
2210 anyway. xoxorich. */
2212 if (S_GET_SEGMENT (symbolP
) == undefined_section
2213 && S_GET_VALUE (symbolP
) == 0)
2215 /* The name might be an undefined .global symbol; be sure to
2216 keep the "external" bit. */
2217 S_SET_SEGMENT (symbolP
,
2218 (exp
.X_op
== O_constant
2221 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2225 as_bad (_("symbol `%s' is already defined"), name
);
2229 demand_empty_rest_of_line ();
2232 /* Read a line into an sb. */
2238 char quote1
, quote2
, inquote
;
2240 if (input_line_pointer
[-1] == '\n')
2241 bump_line_counters ();
2243 if (input_line_pointer
>= buffer_limit
)
2245 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2246 if (buffer_limit
== 0)
2250 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2251 code needs to be changed. */
2260 #ifdef LEX_IS_STRINGQUOTE
2266 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2267 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2269 if (inquote
== *input_line_pointer
)
2271 else if (inquote
== '\0')
2273 if (*input_line_pointer
== quote1
)
2275 else if (*input_line_pointer
== quote2
)
2279 sb_add_char (line
, *input_line_pointer
++);
2282 while (input_line_pointer
< buffer_limit
2283 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2285 if (input_line_pointer
[-1] == '\n')
2286 bump_line_counters ();
2287 ++input_line_pointer
;
2293 /* Define a macro. This is an interface to macro.c, which is shared
2294 between gas and gasp. */
2298 int ignore ATTRIBUTE_UNUSED
;
2307 as_where (&file
, &line
);
2310 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2311 sb_add_char (&s
, *input_line_pointer
++);
2314 if (line_label
!= NULL
)
2315 sb_add_string (&label
, S_GET_NAME (line_label
));
2317 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2319 as_bad_where (file
, line
, "%s", err
);
2322 if (line_label
!= NULL
)
2324 S_SET_SEGMENT (line_label
, undefined_section
);
2325 S_SET_VALUE (line_label
, 0);
2326 symbol_set_frag (line_label
, &zero_address_frag
);
2329 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2330 && hash_find (po_hash
, name
) != NULL
)
2333 && hash_find (po_hash
, name
+ 1) != NULL
))
2334 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2341 /* Handle the .mexit pseudo-op, which immediately exits a macro
2346 int ignore ATTRIBUTE_UNUSED
;
2348 cond_exit_macro (macro_nest
);
2349 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2352 /* Switch in and out of MRI mode. */
2356 int ignore ATTRIBUTE_UNUSED
;
2360 on
= get_absolute_expression ();
2361 old_flag
= flag_mri
;
2379 /* Operator precedence changes in m68k MRI mode, so we need to
2380 update the operator rankings. */
2381 expr_set_precedence ();
2383 #ifdef MRI_MODE_CHANGE
2385 MRI_MODE_CHANGE (on
);
2388 demand_empty_rest_of_line ();
2391 /* Handle changing the location counter. */
2394 do_org (segment
, exp
, fill
)
2399 if (segment
!= now_seg
&& segment
!= absolute_section
)
2400 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2402 if (now_seg
== absolute_section
)
2405 as_warn (_("ignoring fill value in absolute section"));
2406 if (exp
->X_op
!= O_constant
)
2408 as_bad (_("only constant offsets supported in absolute section"));
2409 exp
->X_add_number
= 0;
2411 abs_section_offset
= exp
->X_add_number
;
2416 symbolS
*sym
= exp
->X_add_symbol
;
2417 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2419 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2421 /* Handle complex expressions. */
2422 sym
= make_expr_symbol (exp
);
2426 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2433 int ignore ATTRIBUTE_UNUSED
;
2435 register segT segment
;
2437 register long temp_fill
;
2439 #ifdef md_flush_pending_output
2440 md_flush_pending_output ();
2443 /* The m68k MRI assembler has a different meaning for .org. It
2444 means to create an absolute section at a given address. We can't
2445 support that--use a linker script instead. */
2448 as_bad (_("MRI style ORG pseudo-op not supported"));
2449 ignore_rest_of_line ();
2453 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2454 thing as a sub-segment-relative origin. Any absolute origin is
2455 given a warning, then assumed to be segment-relative. Any
2456 segmented origin expression ("foo+42") had better be in the right
2457 segment or the .org is ignored.
2459 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2460 we never know sub-segment sizes when we are reading code. BSD
2461 will crash trying to emit negative numbers of filler bytes in
2462 certain .orgs. We don't crash, but see as-write for that code.
2464 Don't make frag if need_pass_2==1. */
2465 segment
= get_known_segmented_expression (&exp
);
2466 if (*input_line_pointer
== ',')
2468 input_line_pointer
++;
2469 temp_fill
= get_absolute_expression ();
2475 do_org (segment
, &exp
, temp_fill
);
2477 demand_empty_rest_of_line ();
2480 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2481 called by the obj-format routine which handles section changing
2482 when in MRI mode. It will create a new section, and return it. It
2483 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2484 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2485 flags will be set in the section. */
2489 char *type ATTRIBUTE_UNUSED
;
2499 name
= input_line_pointer
;
2500 if (!ISDIGIT (*name
))
2501 c
= get_symbol_end ();
2506 ++input_line_pointer
;
2508 while (ISDIGIT (*input_line_pointer
));
2510 c
= *input_line_pointer
;
2511 *input_line_pointer
= '\0';
2514 name
= xstrdup (name
);
2516 *input_line_pointer
= c
;
2518 seg
= subseg_new (name
, 0);
2520 if (*input_line_pointer
== ',')
2524 ++input_line_pointer
;
2525 align
= get_absolute_expression ();
2526 record_alignment (seg
, align
);
2530 if (*input_line_pointer
== ',')
2532 c
= *++input_line_pointer
;
2534 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2537 as_bad (_("unrecognized section type"));
2538 ++input_line_pointer
;
2540 #ifdef BFD_ASSEMBLER
2544 flags
= SEC_NO_FLAGS
;
2546 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2547 else if (*type
== 'D' || *type
== 'M')
2548 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2549 else if (*type
== 'R')
2550 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2551 if (flags
!= SEC_NO_FLAGS
)
2553 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2554 as_warn (_("error setting flags for \"%s\": %s"),
2555 bfd_section_name (stdoutput
, seg
),
2556 bfd_errmsg (bfd_get_error ()));
2562 /* Ignore the HP type. */
2563 if (*input_line_pointer
== ',')
2564 input_line_pointer
+= 2;
2566 demand_empty_rest_of_line ();
2568 #else /* ! TC_M68K */
2577 name
= input_line_pointer
;
2578 c
= get_symbol_end ();
2580 name
= xstrdup (name
);
2582 *input_line_pointer
= c
;
2584 seg
= subseg_new (name
, 0);
2586 if (*input_line_pointer
!= ',')
2592 ++input_line_pointer
;
2594 sectype
= input_line_pointer
;
2595 c
= get_symbol_end ();
2596 if (*sectype
== '\0')
2598 else if (strcasecmp (sectype
, "text") == 0)
2600 else if (strcasecmp (sectype
, "data") == 0)
2602 else if (strcasecmp (sectype
, "romdata") == 0)
2605 as_warn (_("unrecognized section type `%s'"), sectype
);
2606 *input_line_pointer
= c
;
2609 if (*input_line_pointer
== ',')
2613 ++input_line_pointer
;
2615 seccmd
= input_line_pointer
;
2616 c
= get_symbol_end ();
2617 if (strcasecmp (seccmd
, "absolute") == 0)
2619 as_bad (_("absolute sections are not supported"));
2620 *input_line_pointer
= c
;
2621 ignore_rest_of_line ();
2624 else if (strcasecmp (seccmd
, "align") == 0)
2628 *input_line_pointer
= c
;
2629 align
= get_absolute_expression ();
2630 record_alignment (seg
, align
);
2634 as_warn (_("unrecognized section command `%s'"), seccmd
);
2635 *input_line_pointer
= c
;
2639 demand_empty_rest_of_line ();
2641 #else /* ! TC_I960 */
2642 /* The MRI assembler seems to use different forms of .sect for
2643 different targets. */
2644 as_bad ("MRI mode not supported for this target");
2645 ignore_rest_of_line ();
2646 #endif /* ! TC_I960 */
2647 #endif /* ! TC_M68K */
2650 /* Handle the .print pseudo-op. */
2654 int ignore ATTRIBUTE_UNUSED
;
2659 s
= demand_copy_C_string (&len
);
2661 demand_empty_rest_of_line ();
2664 /* Handle the .purgem pseudo-op. */
2668 int ignore ATTRIBUTE_UNUSED
;
2670 if (is_it_end_of_statement ())
2672 demand_empty_rest_of_line ();
2682 name
= input_line_pointer
;
2683 c
= get_symbol_end ();
2684 delete_macro (name
);
2685 *input_line_pointer
= c
;
2688 while (*input_line_pointer
++ == ',');
2690 --input_line_pointer
;
2691 demand_empty_rest_of_line ();
2694 /* Handle the .rept pseudo-op. */
2698 int ignore ATTRIBUTE_UNUSED
;
2702 count
= get_absolute_expression ();
2704 do_repeat (count
, "REPT", "ENDR");
2707 /* This function provides a generic repeat block implementation. It allows
2708 different directives to be used as the start/end keys. */
2711 do_repeat (count
, start
, end
)
2720 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2722 as_bad (_("%s without %s"), start
, end
);
2728 sb_add_sb (&many
, &one
);
2732 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2734 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2737 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2738 input buffers to skip. Assumes that conditionals preceding the loop end
2739 are properly nested.
2741 This function makes it easier to implement a premature "break" out of the
2742 loop. The EXTRA arg accounts for other buffers we might have inserted,
2743 such as line substitutions. */
2749 cond_exit_macro (macro_nest
);
2750 while (extra
-- >= 0)
2751 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2754 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2755 this is .equiv, and it is an error if the symbol is already
2762 register char *name
;
2763 register char delim
;
2764 register char *end_name
;
2765 register symbolS
*symbolP
;
2767 /* Especial apologies for the random logic:
2768 this just grew, and could be parsed much more simply!
2770 name
= input_line_pointer
;
2771 delim
= get_symbol_end ();
2772 end_name
= input_line_pointer
;
2775 if (name
== end_name
)
2777 as_bad (_("expected symbol name"));
2778 discard_rest_of_line ();
2784 if (*input_line_pointer
!= ',')
2787 as_bad (_("expected comma after \"%s\""), name
);
2789 ignore_rest_of_line ();
2793 input_line_pointer
++;
2796 if (name
[0] == '.' && name
[1] == '\0')
2798 /* Turn '. = mumble' into a .org mumble. */
2799 register segT segment
;
2802 segment
= get_known_segmented_expression (&exp
);
2805 do_org (segment
, &exp
, 0);
2811 if ((symbolP
= symbol_find (name
)) == NULL
2812 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2815 /* When doing symbol listings, play games with dummy fragments living
2816 outside the normal fragment chain to record the file and line info
2818 if (listing
& LISTING_SYMBOLS
)
2820 extern struct list_info_struct
*listing_tail
;
2821 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2822 memset (dummy_frag
, 0, sizeof (fragS
));
2823 dummy_frag
->fr_type
= rs_fill
;
2824 dummy_frag
->line
= listing_tail
;
2825 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2826 dummy_frag
->fr_symbol
= symbolP
;
2830 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2833 /* "set" symbols are local unless otherwise specified. */
2834 SF_SET_LOCAL (symbolP
);
2835 #endif /* OBJ_COFF */
2838 symbol_table_insert (symbolP
);
2843 && S_IS_DEFINED (symbolP
)
2844 && S_GET_SEGMENT (symbolP
) != reg_section
)
2845 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2847 pseudo_set (symbolP
);
2848 demand_empty_rest_of_line ();
2862 #ifdef md_flush_pending_output
2863 md_flush_pending_output ();
2867 stop
= mri_comment_field (&stopc
);
2869 /* In m68k MRI mode, we need to align to a word boundary, unless
2871 if (flag_m68k_mri
&& mult
> 1)
2873 if (now_seg
== absolute_section
)
2875 abs_section_offset
+= abs_section_offset
& 1;
2876 if (line_label
!= NULL
)
2877 S_SET_VALUE (line_label
, abs_section_offset
);
2879 else if (mri_common_symbol
!= NULL
)
2883 val
= S_GET_VALUE (mri_common_symbol
);
2886 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2887 if (line_label
!= NULL
)
2889 expressionS
*symexp
;
2891 symexp
= symbol_get_value_expression (line_label
);
2892 know (symexp
->X_op
== O_symbol
);
2893 know (symexp
->X_add_symbol
== mri_common_symbol
);
2894 symexp
->X_add_number
+= 1;
2900 do_align (1, (char *) NULL
, 0, 0);
2901 if (line_label
!= NULL
)
2903 symbol_set_frag (line_label
, frag_now
);
2904 S_SET_VALUE (line_label
, frag_now_fix ());
2914 if (*input_line_pointer
== ',')
2916 ++input_line_pointer
;
2921 val
.X_op
= O_constant
;
2922 val
.X_add_number
= 0;
2925 if (val
.X_op
!= O_constant
2926 || val
.X_add_number
< - 0x80
2927 || val
.X_add_number
> 0xff
2928 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2930 if (exp
.X_op
!= O_constant
)
2931 as_bad (_("unsupported variable size or fill value"));
2938 bytes
= mult
* exp
.X_add_number
;
2939 for (i
= 0; i
< exp
.X_add_number
; i
++)
2940 emit_expr (&val
, mult
);
2945 if (exp
.X_op
== O_constant
)
2949 repeat
= exp
.X_add_number
;
2956 as_warn (_(".space repeat count is zero, ignored"));
2957 else if (repeat
< 0)
2958 as_warn (_(".space repeat count is negative, ignored"));
2962 /* If we are in the absolute section, just bump the offset. */
2963 if (now_seg
== absolute_section
)
2965 abs_section_offset
+= repeat
;
2969 /* If we are secretly in an MRI common section, then
2970 creating space just increases the size of the common
2972 if (mri_common_symbol
!= NULL
)
2974 S_SET_VALUE (mri_common_symbol
,
2975 S_GET_VALUE (mri_common_symbol
) + repeat
);
2980 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2981 (offsetT
) repeat
, (char *) 0);
2985 if (now_seg
== absolute_section
)
2987 as_bad (_("space allocation too complex in absolute section"));
2988 subseg_set (text_section
, 0);
2991 if (mri_common_symbol
!= NULL
)
2993 as_bad (_("space allocation too complex in common section"));
2994 mri_common_symbol
= NULL
;
2998 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2999 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
3003 *p
= val
.X_add_number
;
3008 /* In MRI mode, after an odd number of bytes, we must align to an
3009 even word boundary, unless the next instruction is a dc.b, ds.b
3011 if (flag_mri
&& (bytes
& 1) != 0)
3012 mri_pending_align
= 1;
3014 demand_empty_rest_of_line ();
3017 mri_comment_end (stop
, stopc
);
3020 /* This is like s_space, but the value is a floating point number with
3021 the given precision. This is for the MRI dcb.s pseudo-op and
3025 s_float_space (float_type
)
3030 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3035 stop
= mri_comment_field (&stopc
);
3037 count
= get_absolute_expression ();
3040 if (*input_line_pointer
!= ',')
3042 as_bad (_("missing value"));
3043 ignore_rest_of_line ();
3045 mri_comment_end (stop
, stopc
);
3049 ++input_line_pointer
;
3053 /* Skip any 0{letter} that may be present. Don't even check if the
3054 * letter is legal. */
3055 if (input_line_pointer
[0] == '0'
3056 && ISALPHA (input_line_pointer
[1]))
3057 input_line_pointer
+= 2;
3059 /* Accept :xxxx, where the x's are hex digits, for a floating point
3060 with the exact digits specified. */
3061 if (input_line_pointer
[0] == ':')
3063 flen
= hex_float (float_type
, temp
);
3066 ignore_rest_of_line ();
3068 mri_comment_end (stop
, stopc
);
3076 err
= md_atof (float_type
, temp
, &flen
);
3077 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3081 as_bad (_("bad floating literal: %s"), err
);
3082 ignore_rest_of_line ();
3084 mri_comment_end (stop
, stopc
);
3089 while (--count
>= 0)
3093 p
= frag_more (flen
);
3094 memcpy (p
, temp
, (unsigned int) flen
);
3097 demand_empty_rest_of_line ();
3100 mri_comment_end (stop
, stopc
);
3103 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3107 int ignore ATTRIBUTE_UNUSED
;
3113 stop
= mri_comment_field (&stopc
);
3114 abs_section_offset
= get_absolute_expression ();
3115 subseg_set (absolute_section
, 0);
3116 demand_empty_rest_of_line ();
3118 mri_comment_end (stop
, stopc
);
3123 int ignore ATTRIBUTE_UNUSED
;
3127 temp
= get_absolute_expression ();
3128 subseg_set (text_section
, (subsegT
) temp
);
3129 demand_empty_rest_of_line ();
3131 const_flag
&= ~IN_DEFAULT_SECTION
;
3136 demand_empty_rest_of_line ()
3139 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3140 input_line_pointer
++;
3142 ignore_rest_of_line ();
3144 /* Return having already swallowed end-of-line. */
3148 ignore_rest_of_line ()
3150 /* For suspect lines: gives warning. */
3151 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3153 if (ISPRINT (*input_line_pointer
))
3154 as_warn (_("rest of line ignored; first ignored character is `%c'"),
3155 *input_line_pointer
);
3157 as_warn (_("rest of line ignored; first ignored character valued 0x%x"),
3158 *input_line_pointer
);
3160 while (input_line_pointer
< buffer_limit
3161 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3162 input_line_pointer
++;
3165 input_line_pointer
++;
3167 /* Return pointing just after end-of-line. */
3168 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3172 discard_rest_of_line ()
3174 while (input_line_pointer
< buffer_limit
3175 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3176 input_line_pointer
++;
3178 input_line_pointer
++;
3180 /* Return pointing just after end-of-line. */
3181 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3184 /* In: Pointer to a symbol.
3185 Input_line_pointer->expression.
3187 Out: Input_line_pointer->just after any whitespace after expression.
3188 Tried to set symbol to value of expression.
3189 Will change symbols type, value, and frag; */
3192 pseudo_set (symbolP
)
3196 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3198 #endif /* OBJ_AOUT or OBJ_BOUT */
3200 know (symbolP
); /* NULL pointer is logic error. */
3201 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3202 ext
= S_IS_EXTERNAL (symbolP
);
3203 #endif /* OBJ_AOUT or OBJ_BOUT */
3205 (void) expression (&exp
);
3207 if (exp
.X_op
== O_illegal
)
3208 as_bad (_("illegal expression"));
3209 else if (exp
.X_op
== O_absent
)
3210 as_bad (_("missing expression"));
3211 else if (exp
.X_op
== O_big
)
3213 if (exp
.X_add_number
> 0)
3214 as_bad (_("bignum invalid"));
3216 as_bad (_("floating point number invalid"));
3218 else if (exp
.X_op
== O_subtract
3219 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3220 == S_GET_SEGMENT (exp
.X_op_symbol
))
3221 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3222 && (symbol_get_frag (exp
.X_add_symbol
)
3223 == symbol_get_frag (exp
.X_op_symbol
)))
3225 exp
.X_op
= O_constant
;
3226 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3227 - S_GET_VALUE (exp
.X_op_symbol
));
3235 exp
.X_add_number
= 0;
3238 S_SET_SEGMENT (symbolP
, absolute_section
);
3239 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3241 S_SET_EXTERNAL (symbolP
);
3243 S_CLEAR_EXTERNAL (symbolP
);
3244 #endif /* OBJ_AOUT or OBJ_BOUT */
3245 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3246 if (exp
.X_op
!= O_constant
)
3247 symbol_set_frag (symbolP
, &zero_address_frag
);
3251 S_SET_SEGMENT (symbolP
, reg_section
);
3252 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3253 symbol_set_frag (symbolP
, &zero_address_frag
);
3257 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3258 || exp
.X_add_number
!= 0)
3259 symbol_set_value_expression (symbolP
, &exp
);
3260 else if (symbol_section_p (symbolP
))
3261 as_bad ("attempt to set value of section symbol");
3264 symbolS
*s
= exp
.X_add_symbol
;
3266 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3267 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3269 S_SET_EXTERNAL (symbolP
);
3271 S_CLEAR_EXTERNAL (symbolP
);
3272 #endif /* OBJ_AOUT or OBJ_BOUT */
3273 S_SET_VALUE (symbolP
,
3274 exp
.X_add_number
+ S_GET_VALUE (s
));
3275 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3276 copy_symbol_attributes (symbolP
, s
);
3281 /* The value is some complex expression.
3282 FIXME: Should we set the segment to anything? */
3283 symbol_set_value_expression (symbolP
, &exp
);
3290 CONStruct more frag of .bytes, or .words etc.
3291 Should need_pass_2 be 1 then emit no frag(s).
3292 This understands EXPRESSIONS.
3296 This has a split personality. We use expression() to read the
3297 value. We can detect if the value won't fit in a byte or word.
3298 But we can't detect if expression() discarded significant digits
3299 in the case of a long. Not worth the crocks required to fix it. */
3301 /* Select a parser for cons expressions. */
3303 /* Some targets need to parse the expression in various fancy ways.
3304 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3305 (for example, the HPPA does this). Otherwise, you can define
3306 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3307 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3308 are defined, which is the normal case, then only simple expressions
3313 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3316 #ifndef TC_PARSE_CONS_EXPRESSION
3317 #ifdef BITFIELD_CONS_EXPRESSIONS
3318 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3320 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3322 #ifdef REPEAT_CONS_EXPRESSIONS
3323 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3325 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3328 /* If we haven't gotten one yet, just call expression. */
3329 #ifndef TC_PARSE_CONS_EXPRESSION
3330 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3334 /* Worker to do .byte etc statements.
3335 Clobbers input_line_pointer and checks end-of-line. */
3338 cons_worker (nbytes
, rva
)
3339 register int nbytes
; /* 1=.byte, 2=.word, 4=.long. */
3347 #ifdef md_flush_pending_output
3348 md_flush_pending_output ();
3352 stop
= mri_comment_field (&stopc
);
3354 if (is_it_end_of_statement ())
3356 demand_empty_rest_of_line ();
3358 mri_comment_end (stop
, stopc
);
3362 #ifdef md_cons_align
3363 md_cons_align (nbytes
);
3371 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3374 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3378 if (exp
.X_op
== O_symbol
)
3379 exp
.X_op
= O_symbol_rva
;
3381 as_fatal (_("rva without symbol"));
3383 emit_expr (&exp
, (unsigned int) nbytes
);
3386 while (*input_line_pointer
++ == ',');
3388 /* In MRI mode, after an odd number of bytes, we must align to an
3389 even word boundary, unless the next instruction is a dc.b, ds.b
3391 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3392 mri_pending_align
= 1;
3394 input_line_pointer
--; /* Put terminator back into stream. */
3396 demand_empty_rest_of_line ();
3399 mri_comment_end (stop
, stopc
);
3406 cons_worker (size
, 0);
3413 cons_worker (size
, 1);
3416 /* Put the contents of expression EXP into the object file using
3417 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3420 emit_expr (exp
, nbytes
)
3422 unsigned int nbytes
;
3426 valueT extra_digit
= 0;
3428 /* Don't do anything if we are going to make another pass. */
3434 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3435 appear as a four byte positive constant in the .line section,
3436 followed by a 2 byte 0xffff. Look for that case here. */
3438 static int dwarf_line
= -1;
3440 if (strcmp (segment_name (now_seg
), ".line") != 0)
3442 else if (dwarf_line
>= 0
3444 && exp
->X_op
== O_constant
3445 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3446 listing_source_line ((unsigned int) dwarf_line
);
3447 else if (nbytes
== 4
3448 && exp
->X_op
== O_constant
3449 && exp
->X_add_number
>= 0)
3450 dwarf_line
= exp
->X_add_number
;
3455 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3456 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3457 AT_sibling (0x12) followed by a four byte address of the sibling
3458 followed by a 2 byte AT_name (0x38) followed by the name of the
3459 file. We look for that case here. */
3461 static int dwarf_file
= 0;
3463 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3465 else if (dwarf_file
== 0
3467 && exp
->X_op
== O_constant
3468 && exp
->X_add_number
== 0x11)
3470 else if (dwarf_file
== 1
3472 && exp
->X_op
== O_constant
3473 && exp
->X_add_number
== 0x12)
3475 else if (dwarf_file
== 2
3478 else if (dwarf_file
== 3
3480 && exp
->X_op
== O_constant
3481 && exp
->X_add_number
== 0x38)
3486 /* The variable dwarf_file_string tells stringer that the string
3487 may be the name of the source file. */
3488 if (dwarf_file
== 4)
3489 dwarf_file_string
= 1;
3491 dwarf_file_string
= 0;
3496 if (check_eh_frame (exp
, &nbytes
))
3501 /* Allow `.word 0' in the absolute section. */
3502 if (now_seg
== absolute_section
)
3504 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3505 as_bad (_("attempt to store value in absolute section"));
3506 abs_section_offset
+= nbytes
;
3510 /* Handle a negative bignum. */
3512 && exp
->X_add_number
== 0
3513 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3514 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3517 unsigned long carry
;
3519 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3521 /* Negate the bignum: one's complement each digit and add 1. */
3523 for (i
= 0; i
< exp
->X_add_number
; i
++)
3527 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3530 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3531 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3534 /* We can ignore any carry out, because it will be handled by
3535 extra_digit if it is needed. */
3537 extra_digit
= (valueT
) -1;
3541 if (op
== O_absent
|| op
== O_illegal
)
3543 as_warn (_("zero assumed for missing expression"));
3544 exp
->X_add_number
= 0;
3547 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3549 as_bad (_("floating point number invalid"));
3550 exp
->X_add_number
= 0;
3553 else if (op
== O_register
)
3555 as_warn (_("register value used as expression"));
3559 p
= frag_more ((int) nbytes
);
3561 #ifndef WORKING_DOT_WORD
3562 /* If we have the difference of two symbols in a word, save it on
3563 the broken_words list. See the code in write.c. */
3564 if (op
== O_subtract
&& nbytes
== 2)
3566 struct broken_word
*x
;
3568 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3569 x
->next_broken_word
= broken_words
;
3572 x
->subseg
= now_subseg
;
3574 x
->word_goes_here
= p
;
3576 x
->add
= exp
->X_add_symbol
;
3577 x
->sub
= exp
->X_op_symbol
;
3578 x
->addnum
= exp
->X_add_number
;
3585 /* If we have an integer, but the number of bytes is too large to
3586 pass to md_number_to_chars, handle it as a bignum. */
3587 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3592 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3593 extra_digit
= (valueT
) -1;
3594 val
= (valueT
) exp
->X_add_number
;
3598 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3599 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3603 op
= exp
->X_op
= O_big
;
3604 exp
->X_add_number
= gencnt
;
3607 if (op
== O_constant
)
3609 register valueT get
;
3610 register valueT use
;
3611 register valueT mask
;
3613 register valueT unmask
;
3615 /* JF << of >= number of bits in the object is undefined. In
3616 particular SPARC (Sun 4) has problems. */
3617 if (nbytes
>= sizeof (valueT
))
3620 if (nbytes
> sizeof (valueT
))
3623 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3627 /* Don't store these bits. */
3628 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3629 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3632 unmask
= ~mask
; /* Do store these bits. */
3635 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3636 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3639 get
= exp
->X_add_number
;
3641 if ((get
& mask
) != 0
3642 && ((get
& mask
) != mask
3643 || (get
& hibit
) == 0))
3644 { /* Leading bits contain both 0s & 1s. */
3645 as_warn (_("value 0x%lx truncated to 0x%lx"),
3646 (unsigned long) get
, (unsigned long) use
);
3648 /* Put bytes in right order. */
3649 md_number_to_chars (p
, use
, (int) nbytes
);
3651 else if (op
== O_big
)
3654 LITTLENUM_TYPE
*nums
;
3656 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3658 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3661 as_warn (_("bignum truncated to %d bytes"), nbytes
);
3665 if (target_big_endian
)
3667 while (nbytes
> size
)
3669 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3670 nbytes
-= CHARS_PER_LITTLENUM
;
3671 p
+= CHARS_PER_LITTLENUM
;
3674 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3678 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3679 size
-= CHARS_PER_LITTLENUM
;
3680 p
+= CHARS_PER_LITTLENUM
;
3685 nums
= generic_bignum
;
3688 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3690 size
-= CHARS_PER_LITTLENUM
;
3691 p
+= CHARS_PER_LITTLENUM
;
3692 nbytes
-= CHARS_PER_LITTLENUM
;
3697 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3698 nbytes
-= CHARS_PER_LITTLENUM
;
3699 p
+= CHARS_PER_LITTLENUM
;
3705 memset (p
, 0, nbytes
);
3707 /* Now we need to generate a fixS to record the symbol value.
3708 This is easy for BFD. For other targets it can be more
3709 complex. For very complex cases (currently, the HPPA and
3710 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3711 want. For simpler cases, you can define TC_CONS_RELOC to be
3712 the name of the reloc code that should be stored in the fixS.
3713 If neither is defined, the code uses NO_RELOC if it is
3714 defined, and otherwise uses 0. */
3716 #ifdef BFD_ASSEMBLER
3717 #ifdef TC_CONS_FIX_NEW
3718 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3721 bfd_reloc_code_real_type r
;
3738 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3742 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3747 #ifdef TC_CONS_FIX_NEW
3748 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3750 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3751 it is defined, otherwise use NO_RELOC if it is defined,
3753 #ifndef TC_CONS_RELOC
3755 #define TC_CONS_RELOC NO_RELOC
3757 #define TC_CONS_RELOC 0
3760 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3762 #endif /* TC_CONS_FIX_NEW */
3763 #endif /* BFD_ASSEMBLER */
3767 #ifdef BITFIELD_CONS_EXPRESSIONS
3769 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3770 w:x,y:z, where w and y are bitwidths and x and y are values. They
3771 then pack them all together. We do a little better in that we allow
3772 them in words, longs, etc. and we'll pack them in target byte order
3775 The rules are: pack least significat bit first, if a field doesn't
3776 entirely fit, put it in the next unit. Overflowing the bitfield is
3777 explicitly *not* even a warning. The bitwidth should be considered
3780 To use this function the tc-XXX.h file should define
3781 BITFIELD_CONS_EXPRESSIONS. */
3784 parse_bitfield_cons (exp
, nbytes
)
3786 unsigned int nbytes
;
3788 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3789 char *hold
= input_line_pointer
;
3791 (void) expression (exp
);
3793 if (*input_line_pointer
== ':')
3800 unsigned long width
;
3802 if (*input_line_pointer
!= ':')
3804 input_line_pointer
= hold
;
3806 } /* Next piece is not a bitfield. */
3808 /* In the general case, we can't allow
3809 full expressions with symbol
3810 differences and such. The relocation
3811 entries for symbols not defined in this
3812 assembly would require arbitrary field
3813 widths, positions, and masks which most
3814 of our current object formats don't
3817 In the specific case where a symbol
3818 *is* defined in this assembly, we
3819 *could* build fixups and track it, but
3820 this could lead to confusion for the
3821 backends. I'm lazy. I'll take any
3822 SEG_ABSOLUTE. I think that means that
3823 you can use a previous .set or
3824 .equ type symbol. xoxorich. */
3826 if (exp
->X_op
== O_absent
)
3828 as_warn (_("using a bit field width of zero"));
3829 exp
->X_add_number
= 0;
3830 exp
->X_op
= O_constant
;
3831 } /* Implied zero width bitfield. */
3833 if (exp
->X_op
!= O_constant
)
3835 *input_line_pointer
= '\0';
3836 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3837 *input_line_pointer
= ':';
3838 demand_empty_rest_of_line ();
3840 } /* Too complex. */
3842 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3844 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3845 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3846 width
= BITS_PER_CHAR
* nbytes
;
3849 if (width
> bits_available
)
3851 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3852 input_line_pointer
= hold
;
3853 exp
->X_add_number
= value
;
3858 hold
= ++input_line_pointer
;
3860 (void) expression (exp
);
3861 if (exp
->X_op
!= O_constant
)
3863 char cache
= *input_line_pointer
;
3865 *input_line_pointer
= '\0';
3866 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3867 *input_line_pointer
= cache
;
3868 demand_empty_rest_of_line ();
3870 } /* Too complex. */
3872 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3873 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3875 if ((bits_available
-= width
) == 0
3876 || is_it_end_of_statement ()
3877 || *input_line_pointer
!= ',')
3880 } /* All the bitfields we're gonna get. */
3882 hold
= ++input_line_pointer
;
3883 (void) expression (exp
);
3886 exp
->X_add_number
= value
;
3887 exp
->X_op
= O_constant
;
3888 exp
->X_unsigned
= 1;
3892 #endif /* BITFIELD_CONS_EXPRESSIONS */
3894 /* Handle an MRI style string expression. */
3898 parse_mri_cons (exp
, nbytes
)
3900 unsigned int nbytes
;
3902 if (*input_line_pointer
!= '\''
3903 && (input_line_pointer
[1] != '\''
3904 || (*input_line_pointer
!= 'A'
3905 && *input_line_pointer
!= 'E')))
3906 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3910 unsigned int result
= 0;
3912 /* An MRI style string. Cut into as many bytes as will fit into
3913 a nbyte chunk, left justify if necessary, and separate with
3914 commas so we can try again later. */
3915 if (*input_line_pointer
== 'A')
3916 ++input_line_pointer
;
3917 else if (*input_line_pointer
== 'E')
3919 as_bad (_("EBCDIC constants are not supported"));
3920 ++input_line_pointer
;
3923 input_line_pointer
++;
3924 for (scan
= 0; scan
< nbytes
; scan
++)
3926 if (*input_line_pointer
== '\'')
3928 if (input_line_pointer
[1] == '\'')
3930 input_line_pointer
++;
3935 result
= (result
<< 8) | (*input_line_pointer
++);
3939 while (scan
< nbytes
)
3945 /* Create correct expression. */
3946 exp
->X_op
= O_constant
;
3947 exp
->X_add_number
= result
;
3949 /* Fake it so that we can read the next char too. */
3950 if (input_line_pointer
[0] != '\'' ||
3951 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3953 input_line_pointer
-= 2;
3954 input_line_pointer
[0] = ',';
3955 input_line_pointer
[1] = '\'';
3958 input_line_pointer
++;
3961 #endif /* TC_M68K */
3963 #ifdef REPEAT_CONS_EXPRESSIONS
3965 /* Parse a repeat expression for cons. This is used by the MIPS
3966 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3967 object file COUNT times.
3969 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3972 parse_repeat_cons (exp
, nbytes
)
3974 unsigned int nbytes
;
3981 if (*input_line_pointer
!= ':')
3983 /* No repeat count. */
3987 ++input_line_pointer
;
3988 expression (&count
);
3989 if (count
.X_op
!= O_constant
3990 || count
.X_add_number
<= 0)
3992 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
3996 /* The cons function is going to output this expression once. So we
3997 output it count - 1 times. */
3998 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3999 emit_expr (exp
, nbytes
);
4002 #endif /* REPEAT_CONS_EXPRESSIONS */
4004 /* Parse a floating point number represented as a hex constant. This
4005 permits users to specify the exact bits they want in the floating
4009 hex_float (float_type
, bytes
)
4043 as_bad (_("unknown floating type type '%c'"), float_type
);
4047 /* It would be nice if we could go through expression to parse the
4048 hex constant, but if we get a bignum it's a pain to sort it into
4049 the buffer correctly. */
4051 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4055 /* The MRI assembler accepts arbitrary underscores strewn about
4056 through the hex constant, so we ignore them as well. */
4057 if (*input_line_pointer
== '_')
4059 ++input_line_pointer
;
4065 as_warn (_("floating point constant too large"));
4068 d
= hex_value (*input_line_pointer
) << 4;
4069 ++input_line_pointer
;
4070 while (*input_line_pointer
== '_')
4071 ++input_line_pointer
;
4072 if (hex_p (*input_line_pointer
))
4074 d
+= hex_value (*input_line_pointer
);
4075 ++input_line_pointer
;
4077 if (target_big_endian
)
4080 bytes
[length
- i
- 1] = d
;
4086 if (target_big_endian
)
4087 memset (bytes
+ i
, 0, length
- i
);
4089 memset (bytes
, 0, length
- i
);
4097 CONStruct some more frag chars of .floats .ffloats etc.
4098 Makes 0 or more new frags.
4099 If need_pass_2 == 1, no frags are emitted.
4100 This understands only floating literals, not expressions. Sorry.
4102 A floating constant is defined by atof_generic(), except it is preceded
4103 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4104 reading, I decided to be incompatible. This always tries to give you
4105 rounded bits to the precision of the pseudo-op. Former AS did premature
4106 truncatation, restored noisy bits instead of trailing 0s AND gave you
4107 a choice of 2 flavours of noise according to which of 2 floating-point
4108 scanners you directed AS to use.
4110 In: input_line_pointer->whitespace before, or '0' of flonum. */
4113 float_cons (float_type
)
4114 /* Clobbers input_line-pointer, checks end-of-line. */
4115 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4118 int length
; /* Number of chars in an object. */
4119 register char *err
; /* Error from scanning floating literal. */
4120 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4122 if (is_it_end_of_statement ())
4124 demand_empty_rest_of_line ();
4128 #ifdef md_flush_pending_output
4129 md_flush_pending_output ();
4134 /* input_line_pointer->1st char of a flonum (we hope!). */
4137 /* Skip any 0{letter} that may be present. Don't even check if the
4138 letter is legal. Someone may invent a "z" format and this routine
4139 has no use for such information. Lusers beware: you get
4140 diagnostics if your input is ill-conditioned. */
4141 if (input_line_pointer
[0] == '0'
4142 && ISALPHA (input_line_pointer
[1]))
4143 input_line_pointer
+= 2;
4145 /* Accept :xxxx, where the x's are hex digits, for a floating
4146 point with the exact digits specified. */
4147 if (input_line_pointer
[0] == ':')
4149 ++input_line_pointer
;
4150 length
= hex_float (float_type
, temp
);
4153 ignore_rest_of_line ();
4159 err
= md_atof (float_type
, temp
, &length
);
4160 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4164 as_bad (_("bad floating literal: %s"), err
);
4165 ignore_rest_of_line ();
4176 #ifdef REPEAT_CONS_EXPRESSIONS
4177 if (*input_line_pointer
== ':')
4179 expressionS count_exp
;
4181 ++input_line_pointer
;
4182 expression (&count_exp
);
4184 if (count_exp
.X_op
!= O_constant
4185 || count_exp
.X_add_number
<= 0)
4186 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4188 count
= count_exp
.X_add_number
;
4192 while (--count
>= 0)
4194 p
= frag_more (length
);
4195 memcpy (p
, temp
, (unsigned int) length
);
4200 while (*input_line_pointer
++ == ',');
4202 /* Put terminator back into stream. */
4203 --input_line_pointer
;
4204 demand_empty_rest_of_line ();
4207 /* Return the size of a LEB128 value. */
4210 sizeof_sleb128 (value
)
4213 register int size
= 0;
4214 register unsigned byte
;
4218 byte
= (value
& 0x7f);
4219 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4220 Fortunately, we can structure things so that the extra work reduces
4221 to a noop on systems that do things "properly". */
4222 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4225 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4226 || ((value
== -1) && ((byte
& 0x40) != 0))));
4232 sizeof_uleb128 (value
)
4235 register int size
= 0;
4236 register unsigned byte
;
4240 byte
= (value
& 0x7f);
4250 sizeof_leb128 (value
, sign
)
4255 return sizeof_sleb128 ((offsetT
) value
);
4257 return sizeof_uleb128 (value
);
4260 /* Output a LEB128 value. */
4263 output_sleb128 (p
, value
)
4267 register char *orig
= p
;
4272 unsigned byte
= (value
& 0x7f);
4274 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4275 Fortunately, we can structure things so that the extra work reduces
4276 to a noop on systems that do things "properly". */
4277 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4279 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4280 || ((value
== -1) && ((byte
& 0x40) != 0))));
4292 output_uleb128 (p
, value
)
4300 unsigned byte
= (value
& 0x7f);
4303 /* More bytes to follow. */
4314 output_leb128 (p
, value
, sign
)
4320 return output_sleb128 (p
, (offsetT
) value
);
4322 return output_uleb128 (p
, value
);
4325 /* Do the same for bignums. We combine sizeof with output here in that
4326 we don't output for NULL values of P. It isn't really as critical as
4327 for "normal" values that this be streamlined. */
4330 output_big_sleb128 (p
, bignum
, size
)
4332 LITTLENUM_TYPE
*bignum
;
4340 /* Strip leading sign extensions off the bignum. */
4341 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4346 if (loaded
< 7 && size
> 0)
4348 val
|= (*bignum
<< loaded
);
4349 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4360 if ((val
== 0 && (byte
& 0x40) == 0)
4361 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4362 && (byte
& 0x40) != 0))
4370 while (byte
& 0x80);
4376 output_big_uleb128 (p
, bignum
, size
)
4378 LITTLENUM_TYPE
*bignum
;
4386 /* Strip leading zeros off the bignum. */
4387 /* XXX: Is this needed? */
4388 while (size
> 0 && bignum
[size
- 1] == 0)
4393 if (loaded
< 7 && size
> 0)
4395 val
|= (*bignum
<< loaded
);
4396 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4405 if (size
> 0 || val
)
4412 while (byte
& 0x80);
4418 output_big_leb128 (p
, bignum
, size
, sign
)
4420 LITTLENUM_TYPE
*bignum
;
4424 return output_big_sleb128 (p
, bignum
, size
);
4426 return output_big_uleb128 (p
, bignum
, size
);
4429 /* Generate the appropriate fragments for a given expression to emit a
4433 emit_leb128_expr (exp
, sign
)
4437 operatorT op
= exp
->X_op
;
4440 if (op
== O_absent
|| op
== O_illegal
)
4442 as_warn (_("zero assumed for missing expression"));
4443 exp
->X_add_number
= 0;
4446 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4448 as_bad (_("floating point number invalid"));
4449 exp
->X_add_number
= 0;
4452 else if (op
== O_register
)
4454 as_warn (_("register value used as expression"));
4458 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
4459 a signal that this is leb128 data. It shouldn't optimize this away. */
4461 if (check_eh_frame (exp
, &nbytes
))
4464 /* Let the backend know that subsequent data may be byte aligned. */
4465 #ifdef md_cons_align
4469 if (op
== O_constant
)
4471 /* If we've got a constant, emit the thing directly right now. */
4473 valueT value
= exp
->X_add_number
;
4477 size
= sizeof_leb128 (value
, sign
);
4478 p
= frag_more (size
);
4479 output_leb128 (p
, value
, sign
);
4481 else if (op
== O_big
)
4483 /* O_big is a different sort of constant. */
4488 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4489 p
= frag_more (size
);
4490 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4494 /* Otherwise, we have to create a variable sized fragment and
4495 resolve things later. */
4497 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4498 make_expr_symbol (exp
), 0, (char *) NULL
);
4502 /* Parse the .sleb128 and .uleb128 pseudos. */
4513 emit_leb128_expr (&exp
, sign
);
4515 while (*input_line_pointer
++ == ',');
4517 input_line_pointer
--;
4518 demand_empty_rest_of_line ();
4521 /* We read 0 or more ',' separated, double-quoted strings.
4522 Caller should have checked need_pass_2 is FALSE because we don't
4526 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4527 /* Checks end-of-line. */
4528 register int append_zero
; /* 0: don't append '\0', else 1. */
4530 register unsigned int c
;
4533 #ifdef md_flush_pending_output
4534 md_flush_pending_output ();
4537 /* The following awkward logic is to parse ZERO or more strings,
4538 comma separated. Recall a string expression includes spaces
4539 before the opening '\"' and spaces after the closing '\"'.
4540 We fake a leading ',' if there is (supposed to be)
4541 a 1st, expression. We keep demanding expressions for each ','. */
4542 if (is_it_end_of_statement ())
4544 c
= 0; /* Skip loop. */
4545 ++input_line_pointer
; /* Compensate for end of loop. */
4549 c
= ','; /* Do loop. */
4551 while (c
== ',' || c
== '<' || c
== '"')
4554 switch (*input_line_pointer
)
4557 ++input_line_pointer
; /*->1st char of string. */
4558 start
= input_line_pointer
;
4559 while (is_a_char (c
= next_char_of_string ()))
4561 FRAG_APPEND_1_CHAR (c
);
4565 FRAG_APPEND_1_CHAR (0);
4567 know (input_line_pointer
[-1] == '\"');
4571 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4572 will emit .string with a filename in the .debug section
4573 after a sequence of constants. See the comment in
4574 emit_expr for the sequence. emit_expr will set
4575 dwarf_file_string to non-zero if this string might be a
4576 source file name. */
4577 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4578 dwarf_file_string
= 0;
4579 else if (dwarf_file_string
)
4581 c
= input_line_pointer
[-1];
4582 input_line_pointer
[-1] = '\0';
4583 listing_source_file (start
);
4584 input_line_pointer
[-1] = c
;
4591 input_line_pointer
++;
4592 c
= get_single_number ();
4593 FRAG_APPEND_1_CHAR (c
);
4594 if (*input_line_pointer
!= '>')
4596 as_bad (_("expected <nn>"));
4598 input_line_pointer
++;
4601 input_line_pointer
++;
4605 c
= *input_line_pointer
;
4608 demand_empty_rest_of_line ();
4611 /* FIXME-SOMEDAY: I had trouble here on characters with the
4612 high bits set. We'll probably also have trouble with
4613 multibyte chars, wide chars, etc. Also be careful about
4614 returning values bigger than 1 byte. xoxorich. */
4617 next_char_of_string ()
4619 register unsigned int c
;
4621 c
= *input_line_pointer
++ & CHAR_MASK
;
4629 as_warn (_("unterminated string; newline inserted"));
4630 bump_line_counters ();
4633 #ifndef NO_STRING_ESCAPES
4635 switch (c
= *input_line_pointer
++)
4663 break; /* As itself. */
4679 for (i
= 0, number
= 0;
4680 ISDIGIT (c
) && i
< 3;
4681 c
= *input_line_pointer
++, i
++)
4683 number
= number
* 8 + c
- '0';
4688 --input_line_pointer
;
4697 c
= *input_line_pointer
++;
4698 while (ISXDIGIT (c
))
4701 number
= number
* 16 + c
- '0';
4702 else if (ISUPPER (c
))
4703 number
= number
* 16 + c
- 'A' + 10;
4705 number
= number
* 16 + c
- 'a' + 10;
4706 c
= *input_line_pointer
++;
4709 --input_line_pointer
;
4714 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4715 as_warn (_("unterminated string; newline inserted"));
4717 bump_line_counters ();
4722 #ifdef ONLY_STANDARD_ESCAPES
4723 as_bad (_("bad escaped character in string"));
4725 #endif /* ONLY_STANDARD_ESCAPES */
4730 #endif /* ! defined (NO_STRING_ESCAPES) */
4739 get_segmented_expression (expP
)
4740 register expressionS
*expP
;
4742 register segT retval
;
4744 retval
= expression (expP
);
4745 if (expP
->X_op
== O_illegal
4746 || expP
->X_op
== O_absent
4747 || expP
->X_op
== O_big
)
4749 as_bad (_("expected address expression"));
4750 expP
->X_op
= O_constant
;
4751 expP
->X_add_number
= 0;
4752 retval
= absolute_section
;
4758 get_known_segmented_expression (expP
)
4759 register expressionS
*expP
;
4761 register segT retval
;
4763 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4765 /* There is no easy way to extract the undefined symbol from the
4767 if (expP
->X_add_symbol
!= NULL
4768 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4769 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4770 S_GET_NAME (expP
->X_add_symbol
));
4772 as_warn (_("some symbol undefined; zero assumed"));
4773 retval
= absolute_section
;
4774 expP
->X_op
= O_constant
;
4775 expP
->X_add_number
= 0;
4777 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4782 get_absolute_expression ()
4787 if (exp
.X_op
!= O_constant
)
4789 if (exp
.X_op
!= O_absent
)
4790 as_bad (_("bad or irreducible absolute expression"));
4791 exp
.X_add_number
= 0;
4793 return exp
.X_add_number
;
4796 char /* Return terminator. */
4797 get_absolute_expression_and_terminator (val_pointer
)
4798 long *val_pointer
; /* Return value of expression. */
4800 /* FIXME: val_pointer should probably be offsetT *. */
4801 *val_pointer
= (long) get_absolute_expression ();
4802 return (*input_line_pointer
++);
4805 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4806 Give a warning if that happens. */
4809 demand_copy_C_string (len_pointer
)
4814 if ((s
= demand_copy_string (len_pointer
)) != 0)
4818 for (len
= *len_pointer
; len
> 0; len
--)
4825 as_bad (_("this string may not contain \'\\0\'"));
4833 /* Demand string, but return a safe (=private) copy of the string.
4834 Return NULL if we can't read a string here. */
4837 demand_copy_string (lenP
)
4840 register unsigned int c
;
4846 if (*input_line_pointer
== '\"')
4848 input_line_pointer
++; /* Skip opening quote. */
4850 while (is_a_char (c
= next_char_of_string ()))
4852 obstack_1grow (¬es
, c
);
4855 /* JF this next line is so demand_copy_C_string will return a
4856 null terminated string. */
4857 obstack_1grow (¬es
, '\0');
4858 retval
= obstack_finish (¬es
);
4862 as_warn (_("missing string"));
4864 ignore_rest_of_line ();
4870 /* In: Input_line_pointer->next character.
4872 Do: Skip input_line_pointer over all whitespace.
4874 Out: 1 if input_line_pointer->end-of-line. */
4877 is_it_end_of_statement ()
4880 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4884 equals (sym_name
, reassign
)
4888 register symbolS
*symbolP
; /* Symbol we are working with. */
4892 input_line_pointer
++;
4893 if (*input_line_pointer
== '=')
4894 input_line_pointer
++;
4896 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4897 input_line_pointer
++;
4900 stop
= mri_comment_field (&stopc
);
4902 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4904 /* Turn '. = mumble' into a .org mumble. */
4905 register segT segment
;
4908 segment
= get_known_segmented_expression (&exp
);
4910 do_org (segment
, &exp
, 0);
4917 symbolP
= symbol_find (sym_name
);
4918 local
= symbolP
== NULL
;
4920 #endif /* OBJ_COFF */
4921 symbolP
= symbol_find_or_make (sym_name
);
4922 /* Permit register names to be redefined. */
4924 && S_IS_DEFINED (symbolP
)
4925 && S_GET_SEGMENT (symbolP
) != reg_section
)
4926 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
4929 /* "set" symbols are local unless otherwise specified. */
4931 SF_SET_LOCAL (symbolP
);
4932 #endif /* OBJ_COFF */
4934 pseudo_set (symbolP
);
4939 /* Check garbage after the expression. */
4940 ignore_rest_of_line ();
4941 mri_comment_end (stop
, stopc
);
4945 /* .incbin -- include a file verbatim at the current location. */
4949 int x ATTRIBUTE_UNUSED
;
4960 #ifdef md_flush_pending_output
4961 md_flush_pending_output ();
4965 filename
= demand_copy_string (& len
);
4966 if (filename
== NULL
)
4971 /* Look for optional skip and count. */
4972 if (* input_line_pointer
== ',')
4974 ++ input_line_pointer
;
4975 skip
= get_absolute_expression ();
4979 if (* input_line_pointer
== ',')
4981 ++ input_line_pointer
;
4983 count
= get_absolute_expression ();
4985 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
4991 demand_empty_rest_of_line ();
4993 /* Try opening absolute path first, then try include dirs. */
4994 binfile
= fopen (filename
, FOPEN_RB
);
4995 if (binfile
== NULL
)
4999 path
= xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
5001 for (i
= 0; i
< include_dir_count
; i
++)
5003 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
5005 binfile
= fopen (path
, FOPEN_RB
);
5006 if (binfile
!= NULL
)
5010 if (binfile
== NULL
)
5011 as_bad (_("file not found: %s"), filename
);
5014 path
= xstrdup (filename
);
5020 register_dependency (path
);
5022 /* Compute the length of the file. */
5023 if (fseek (binfile
, 0, SEEK_END
) != 0)
5025 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
5028 file_len
= ftell (binfile
);
5030 /* If a count was not specified use the size of the file. */
5034 if (skip
+ count
> file_len
)
5036 as_bad (_("skip (%ld) + count (%ld) larger than file size (%ld)"),
5037 skip
, count
, file_len
);
5041 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
5043 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
5047 /* Allocate frag space and store file contents in it. */
5048 binfrag
= frag_more (count
);
5050 bytes
= fread (binfrag
, 1, count
, binfile
);
5052 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5053 path
, bytes
, count
);
5056 if (binfile
!= NULL
)
5062 /* .include -- include a file at this point. */
5066 int arg ATTRIBUTE_UNUSED
;
5075 filename
= demand_copy_string (&i
);
5076 if (filename
== NULL
)
5078 /* demand_copy_string has already printed an error and
5079 called ignore_rest_of_line. */
5087 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5088 && *input_line_pointer
!= ' '
5089 && *input_line_pointer
!= '\t')
5091 obstack_1grow (¬es
, *input_line_pointer
);
5092 ++input_line_pointer
;
5096 obstack_1grow (¬es
, '\0');
5097 filename
= obstack_finish (¬es
);
5098 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5099 ++input_line_pointer
;
5102 demand_empty_rest_of_line ();
5103 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
5105 for (i
= 0; i
< include_dir_count
; i
++)
5107 strcpy (path
, include_dirs
[i
]);
5109 strcat (path
, filename
);
5110 if (0 != (try = fopen (path
, FOPEN_RT
)))
5120 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5121 register_dependency (path
);
5122 input_scrub_insert_file (path
);
5126 add_include_dir (path
)
5131 if (include_dir_count
== 0)
5133 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5134 include_dirs
[0] = "."; /* Current dir. */
5135 include_dir_count
= 2;
5139 include_dir_count
++;
5141 (char **) realloc (include_dirs
,
5142 include_dir_count
* sizeof (*include_dirs
));
5145 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5148 if (i
> include_dir_maxlen
)
5149 include_dir_maxlen
= i
;
5152 /* Output debugging information to denote the source file. */
5155 generate_file_debug ()
5157 if (debug_type
== DEBUG_STABS
)
5158 stabs_generate_asm_file ();
5161 /* Output line number debugging information for the current source line. */
5164 generate_lineno_debug ()
5168 case DEBUG_UNSPECIFIED
:
5173 stabs_generate_asm_lineno ();
5176 ecoff_generate_asm_lineno ();
5179 /* ??? We could here indicate to dwarf2dbg.c that something
5180 has changed. However, since there is additional backend
5181 support that is required (calling dwarf2_emit_insn), we
5182 let dwarf2dbg.c call as_where on its own. */
5187 /* Output debugging information to mark a function entry point or end point.
5188 END_P is zero for .func, and non-zero for .endfunc. */
5194 do_s_func (end_p
, NULL
);
5197 /* Subroutine of s_func so targets can choose a different default prefix.
5198 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5201 do_s_func (end_p
, default_prefix
)
5203 const char *default_prefix
;
5205 /* Record the current function so that we can issue an error message for
5206 misplaced .func,.endfunc, and also so that .endfunc needs no
5208 static char *current_name
;
5209 static char *current_label
;
5213 if (current_name
== NULL
)
5215 as_bad (_("missing .func"));
5216 ignore_rest_of_line ();
5220 if (debug_type
== DEBUG_STABS
)
5221 stabs_generate_asm_endfunc (current_name
, current_label
);
5223 current_name
= current_label
= NULL
;
5228 char delim1
, delim2
;
5230 if (current_name
!= NULL
)
5232 as_bad (_(".endfunc missing for previous .func"));
5233 ignore_rest_of_line ();
5237 name
= input_line_pointer
;
5238 delim1
= get_symbol_end ();
5239 name
= xstrdup (name
);
5240 *input_line_pointer
= delim1
;
5242 if (*input_line_pointer
!= ',')
5245 asprintf (&label
, "%s%s", default_prefix
, name
);
5248 char leading_char
= 0;
5249 #ifdef BFD_ASSEMBLER
5250 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5252 /* Missing entry point, use function's name with the leading
5255 asprintf (&label
, "%c%s", leading_char
, name
);
5262 ++input_line_pointer
;
5264 label
= input_line_pointer
;
5265 delim2
= get_symbol_end ();
5266 label
= xstrdup (label
);
5267 *input_line_pointer
= delim2
;
5270 if (debug_type
== DEBUG_STABS
)
5271 stabs_generate_asm_func (name
, label
);
5273 current_name
= name
;
5274 current_label
= label
;
5277 demand_empty_rest_of_line ();
5282 int arg ATTRIBUTE_UNUSED
;
5284 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5286 ++input_line_pointer
;
5288 ++input_line_pointer
;
5292 read_print_statistics (file
)
5295 hash_print_statistics (file
, "pseudo-op table", po_hash
);
5298 /* Inserts the given line into the input stream.
5300 This call avoids macro/conditionals nesting checking, since the contents of
5301 the line are assumed to replace the contents of a line already scanned.
5303 An appropriate use of this function would be substition of input lines when
5304 called by md_start_line_hook(). The given line is assumed to already be
5305 properly scrubbed. */
5308 input_scrub_insert_line (line
)
5313 sb_add_string (&newline
, line
);
5314 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
5316 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
5319 /* Insert a file into the input stream; the path must resolve to an actual
5320 file; no include path searching or dependency registering is performed. */
5323 input_scrub_insert_file (path
)
5326 input_scrub_include_file (path
, input_line_pointer
);
5327 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);