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
)
1166 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1169 /* Only make a frag if we HAVE to... */
1170 if (n
!= 0 && !need_pass_2
)
1174 if (subseg_text_p (now_seg
))
1175 frag_align_code (n
, max
);
1177 frag_align (n
, 0, max
);
1180 frag_align (n
, *fill
, max
);
1182 frag_align_pattern (n
, fill
, len
, max
);
1186 just_record_alignment
:
1189 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1192 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1193 (in bytes). A negative ARG is the negative of the length of the
1194 fill pattern. BYTES_P is non-zero if the alignment value should be
1195 interpreted as the byte boundary, rather than the power of 2. */
1198 s_align (arg
, bytes_p
)
1202 register unsigned int align
;
1210 stop
= mri_comment_field (&stopc
);
1212 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1217 align
= arg
; /* Default value from pseudo-op table. */
1221 align
= get_absolute_expression ();
1227 /* Convert to a power of 2. */
1232 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1235 as_bad (_("alignment not a power of 2"));
1244 as_warn (_("alignment too large: %u assumed"), align
);
1247 if (*input_line_pointer
!= ',')
1254 ++input_line_pointer
;
1255 if (*input_line_pointer
== ',')
1259 fill
= get_absolute_expression ();
1264 if (*input_line_pointer
!= ',')
1268 ++input_line_pointer
;
1269 max
= get_absolute_expression ();
1276 as_warn (_("expected fill pattern missing"));
1277 do_align (align
, (char *) NULL
, 0, max
);
1292 do_align (align
, &fill_char
, fill_len
, max
);
1298 if ((size_t) fill_len
> sizeof ab
)
1300 md_number_to_chars (ab
, fill
, fill_len
);
1301 do_align (align
, ab
, fill_len
, max
);
1305 demand_empty_rest_of_line ();
1308 mri_comment_end (stop
, stopc
);
1311 /* Handle the .align pseudo-op on machines where ".align 4" means
1312 align to a 4 byte boundary. */
1321 /* Handle the .align pseudo-op on machines where ".align 4" means align
1322 to a 2**4 boundary. */
1333 int ignore ATTRIBUTE_UNUSED
;
1335 register char *name
;
1339 register symbolS
*symbolP
;
1344 stop
= mri_comment_field (&stopc
);
1346 name
= input_line_pointer
;
1347 c
= get_symbol_end ();
1348 /* Just after name is now '\0'. */
1349 p
= input_line_pointer
;
1354 as_bad (_("expected symbol name"));
1355 discard_rest_of_line ();
1361 if (*input_line_pointer
!= ',')
1364 as_bad (_("expected comma after \"%s\""), name
);
1366 ignore_rest_of_line ();
1368 mri_comment_end (stop
, stopc
);
1372 input_line_pointer
++; /* skip ',' */
1374 if ((temp
= get_absolute_expression ()) < 0)
1376 as_warn (_(".COMMon length (%ld) < 0 ignored"), (long) temp
);
1377 ignore_rest_of_line ();
1379 mri_comment_end (stop
, stopc
);
1384 symbolP
= symbol_find_or_make (name
);
1387 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1389 as_bad (_("symbol `%s' is already defined"),
1390 S_GET_NAME (symbolP
));
1391 ignore_rest_of_line ();
1393 mri_comment_end (stop
, stopc
);
1397 if (S_GET_VALUE (symbolP
))
1399 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1400 as_bad (_("length of .comm \"%s\" is already %ld; not changing to %ld"),
1401 S_GET_NAME (symbolP
),
1402 (long) S_GET_VALUE (symbolP
),
1407 S_SET_VALUE (symbolP
, (valueT
) temp
);
1408 S_SET_EXTERNAL (symbolP
);
1412 extern int flag_one
;
1413 if (!temp
|| !flag_one
)
1414 S_GET_OTHER(symbolP
) = const_flag
;
1416 #endif /* not OBJ_VMS */
1417 know (symbolP
->sy_frag
== &zero_address_frag
);
1419 demand_empty_rest_of_line ();
1422 mri_comment_end (stop
, stopc
);
1425 /* The MRI COMMON pseudo-op. We handle this by creating a common
1426 symbol with the appropriate name. We make s_space do the right
1427 thing by increasing the size. */
1430 s_mri_common (small
)
1431 int small ATTRIBUTE_UNUSED
;
1447 stop
= mri_comment_field (&stopc
);
1451 name
= input_line_pointer
;
1452 if (!ISDIGIT (*name
))
1453 c
= get_symbol_end ();
1458 ++input_line_pointer
;
1460 while (ISDIGIT (*input_line_pointer
));
1462 c
= *input_line_pointer
;
1463 *input_line_pointer
= '\0';
1465 if (line_label
!= NULL
)
1467 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1468 + (input_line_pointer
- name
)
1470 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1475 sym
= symbol_find_or_make (name
);
1476 *input_line_pointer
= c
;
1480 if (*input_line_pointer
!= ',')
1484 ++input_line_pointer
;
1485 align
= get_absolute_expression ();
1488 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1490 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1491 ignore_rest_of_line ();
1492 mri_comment_end (stop
, stopc
);
1496 S_SET_EXTERNAL (sym
);
1497 mri_common_symbol
= sym
;
1501 S_SET_ALIGN (sym
, align
);
1504 if (line_label
!= NULL
)
1507 exp
.X_op
= O_symbol
;
1508 exp
.X_add_symbol
= sym
;
1509 exp
.X_add_number
= 0;
1510 symbol_set_value_expression (line_label
, &exp
);
1511 symbol_set_frag (line_label
, &zero_address_frag
);
1512 S_SET_SEGMENT (line_label
, expr_section
);
1515 /* FIXME: We just ignore the small argument, which distinguishes
1516 COMMON and COMMON.S. I don't know what we can do about it. */
1518 /* Ignore the type and hptype. */
1519 if (*input_line_pointer
== ',')
1520 input_line_pointer
+= 2;
1521 if (*input_line_pointer
== ',')
1522 input_line_pointer
+= 2;
1524 demand_empty_rest_of_line ();
1526 mri_comment_end (stop
, stopc
);
1531 int ignore ATTRIBUTE_UNUSED
;
1536 temp
= get_absolute_expression ();
1537 if (flag_readonly_data_in_text
)
1539 section
= text_section
;
1543 section
= data_section
;
1545 subseg_set (section
, (subsegT
) temp
);
1550 demand_empty_rest_of_line ();
1553 /* Handle the .appfile pseudo-op. This is automatically generated by
1554 do_scrub_chars when a preprocessor # line comment is seen with a
1555 file name. This default definition may be overridden by the object
1556 or CPU specific pseudo-ops. This function is also the default
1557 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1561 s_app_file (appfile
)
1567 /* Some assemblers tolerate immediately following '"'. */
1568 if ((s
= demand_copy_string (&length
)) != 0)
1570 /* If this is a fake .appfile, a fake newline was inserted into
1571 the buffer. Passing -2 to new_logical_line tells it to
1574 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1576 /* In MRI mode, the preprocessor may have inserted an extraneous
1579 && *input_line_pointer
== '\''
1580 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1581 ++input_line_pointer
;
1583 demand_empty_rest_of_line ();
1588 listing_source_file (s
);
1590 register_dependency (s
);
1598 /* Handle the .appline pseudo-op. This is automatically generated by
1599 do_scrub_chars when a preprocessor # line comment is seen. This
1600 default definition may be overridden by the object or CPU specific
1605 int ignore ATTRIBUTE_UNUSED
;
1609 /* The given number is that of the next line. */
1610 l
= get_absolute_expression () - 1;
1612 /* Some of the back ends can't deal with non-positive line numbers.
1613 Besides, it's silly. */
1614 as_warn (_("line numbers must be positive; line number %d rejected"),
1618 new_logical_line ((char *) NULL
, l
);
1621 listing_source_line (l
);
1624 demand_empty_rest_of_line ();
1627 /* Handle the .end pseudo-op. Actually, the real work is done in
1628 read_a_source_file. */
1632 int ignore ATTRIBUTE_UNUSED
;
1636 /* The MRI assembler permits the start symbol to follow .end,
1637 but we don't support that. */
1639 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1640 && *input_line_pointer
!= '*'
1641 && *input_line_pointer
!= '!')
1642 as_warn (_("start address not supported"));
1646 /* Handle the .err pseudo-op. */
1650 int ignore ATTRIBUTE_UNUSED
;
1652 as_bad (_(".err encountered"));
1653 demand_empty_rest_of_line ();
1656 /* Handle the MRI fail pseudo-op. */
1660 int ignore ATTRIBUTE_UNUSED
;
1667 stop
= mri_comment_field (&stopc
);
1669 temp
= get_absolute_expression ();
1671 as_warn (_(".fail %ld encountered"), (long) temp
);
1673 as_bad (_(".fail %ld encountered"), (long) temp
);
1675 demand_empty_rest_of_line ();
1678 mri_comment_end (stop
, stopc
);
1683 int ignore ATTRIBUTE_UNUSED
;
1685 expressionS rep_exp
;
1687 register long fill
= 0;
1690 #ifdef md_flush_pending_output
1691 md_flush_pending_output ();
1694 get_known_segmented_expression (&rep_exp
);
1695 if (*input_line_pointer
== ',')
1697 input_line_pointer
++;
1698 size
= get_absolute_expression ();
1699 if (*input_line_pointer
== ',')
1701 input_line_pointer
++;
1702 fill
= get_absolute_expression ();
1706 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1707 #define BSD_FILL_SIZE_CROCK_8 (8)
1708 if (size
> BSD_FILL_SIZE_CROCK_8
)
1710 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
1711 size
= BSD_FILL_SIZE_CROCK_8
;
1715 as_warn (_("size negative; .fill ignored"));
1718 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1720 if (rep_exp
.X_add_number
< 0)
1721 as_warn (_("repeat < 0; .fill ignored"));
1725 if (size
&& !need_pass_2
)
1727 if (rep_exp
.X_op
== O_constant
)
1729 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1730 (relax_substateT
) 0, (symbolS
*) 0,
1731 (offsetT
) rep_exp
.X_add_number
,
1736 /* We don't have a constant repeat count, so we can't use
1737 rs_fill. We can get the same results out of rs_space,
1738 but its argument is in bytes, so we must multiply the
1739 repeat count by size. */
1742 rep_sym
= make_expr_symbol (&rep_exp
);
1745 expressionS size_exp
;
1746 size_exp
.X_op
= O_constant
;
1747 size_exp
.X_add_number
= size
;
1749 rep_exp
.X_op
= O_multiply
;
1750 rep_exp
.X_add_symbol
= rep_sym
;
1751 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1752 rep_exp
.X_add_number
= 0;
1753 rep_sym
= make_expr_symbol (&rep_exp
);
1756 p
= frag_var (rs_space
, (int) size
, (int) size
,
1757 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1760 memset (p
, 0, (unsigned int) size
);
1762 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1763 flavoured AS. The following bizarre behaviour is to be
1764 compatible with above. I guess they tried to take up to 8
1765 bytes from a 4-byte expression and they forgot to sign
1767 #define BSD_FILL_SIZE_CROCK_4 (4)
1768 md_number_to_chars (p
, (valueT
) fill
,
1769 (size
> BSD_FILL_SIZE_CROCK_4
1770 ? BSD_FILL_SIZE_CROCK_4
1772 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1773 but emits no error message because it seems a legal thing to do.
1774 It is a degenerate case of .fill but could be emitted by a
1777 demand_empty_rest_of_line ();
1782 int ignore ATTRIBUTE_UNUSED
;
1791 stop
= mri_comment_field (&stopc
);
1795 name
= input_line_pointer
;
1796 c
= get_symbol_end ();
1797 symbolP
= symbol_find_or_make (name
);
1798 S_SET_EXTERNAL (symbolP
);
1800 *input_line_pointer
= c
;
1802 c
= *input_line_pointer
;
1805 input_line_pointer
++;
1807 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1813 demand_empty_rest_of_line ();
1816 mri_comment_end (stop
, stopc
);
1819 /* Handle the MRI IRP and IRPC pseudo-ops. */
1831 as_where (&file
, &line
);
1834 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1835 sb_add_char (&s
, *input_line_pointer
++);
1839 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1841 as_bad_where (file
, line
, "%s", err
);
1845 input_scrub_include_sb (&out
, input_line_pointer
, 1);
1847 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1850 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1851 the section to only be linked once. However, this is not supported
1852 by most object file formats. This takes an optional argument,
1853 which is what to do about duplicates. */
1857 int ignore ATTRIBUTE_UNUSED
;
1859 enum linkonce_type type
;
1863 type
= LINKONCE_DISCARD
;
1865 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1870 s
= input_line_pointer
;
1871 c
= get_symbol_end ();
1872 if (strcasecmp (s
, "discard") == 0)
1873 type
= LINKONCE_DISCARD
;
1874 else if (strcasecmp (s
, "one_only") == 0)
1875 type
= LINKONCE_ONE_ONLY
;
1876 else if (strcasecmp (s
, "same_size") == 0)
1877 type
= LINKONCE_SAME_SIZE
;
1878 else if (strcasecmp (s
, "same_contents") == 0)
1879 type
= LINKONCE_SAME_CONTENTS
;
1881 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1883 *input_line_pointer
= c
;
1886 #ifdef obj_handle_link_once
1887 obj_handle_link_once (type
);
1888 #else /* ! defined (obj_handle_link_once) */
1889 #ifdef BFD_ASSEMBLER
1893 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1894 as_warn (_(".linkonce is not supported for this object file format"));
1896 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1897 flags
|= SEC_LINK_ONCE
;
1902 case LINKONCE_DISCARD
:
1903 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1905 case LINKONCE_ONE_ONLY
:
1906 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1908 case LINKONCE_SAME_SIZE
:
1909 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1911 case LINKONCE_SAME_CONTENTS
:
1912 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1915 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1916 as_bad (_("bfd_set_section_flags: %s"),
1917 bfd_errmsg (bfd_get_error ()));
1919 #else /* ! defined (BFD_ASSEMBLER) */
1920 as_warn (_(".linkonce is not supported for this object file format"));
1921 #endif /* ! defined (BFD_ASSEMBLER) */
1922 #endif /* ! defined (obj_handle_link_once) */
1924 demand_empty_rest_of_line ();
1928 s_lcomm_internal (needs_align
, bytes_p
)
1929 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1930 (alignment); 0 if it was an ".lcomm" (2 args only). */
1932 /* 1 if the alignment value should be interpreted as the byte boundary,
1933 rather than the power of 2. */
1936 register char *name
;
1940 register symbolS
*symbolP
;
1941 segT current_seg
= now_seg
;
1942 subsegT current_subseg
= now_subseg
;
1943 const int max_alignment
= 15;
1945 segT bss_seg
= bss_section
;
1947 name
= input_line_pointer
;
1948 c
= get_symbol_end ();
1949 p
= input_line_pointer
;
1954 as_bad (_("expected symbol name"));
1955 discard_rest_of_line ();
1961 /* Accept an optional comma after the name. The comma used to be
1962 required, but Irix 5 cc does not generate it. */
1963 if (*input_line_pointer
== ',')
1965 ++input_line_pointer
;
1969 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1971 as_bad (_("missing size expression"));
1975 if ((temp
= get_absolute_expression ()) < 0)
1977 as_warn (_("BSS length (%d) < 0 ignored"), temp
);
1978 ignore_rest_of_line ();
1982 #if defined (TC_MIPS) || defined (TC_ALPHA)
1983 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1984 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1986 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1987 if ((unsigned) temp
<= bfd_get_gp_size (stdoutput
))
1989 bss_seg
= subseg_new (".sbss", 1);
1990 seg_info (bss_seg
)->bss
= 1;
1991 #ifdef BFD_ASSEMBLER
1992 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1993 as_warn (_("error setting flags for \".sbss\": %s"),
1994 bfd_errmsg (bfd_get_error ()));
2002 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
2004 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
2006 record_alignment (bss_seg
, align
);
2014 if (*input_line_pointer
!= ',')
2016 as_bad (_("expected comma after size"));
2017 ignore_rest_of_line ();
2021 input_line_pointer
++;
2024 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2026 as_bad (_("missing alignment"));
2030 align
= get_absolute_expression ();
2034 /* Convert to a power of 2. */
2039 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2042 as_bad (_("alignment not a power of 2"));
2047 if (align
> max_alignment
)
2049 align
= max_alignment
;
2050 as_warn (_("alignment too large; %d assumed"), align
);
2055 as_warn (_("alignment negative; 0 assumed"));
2058 record_alignment (bss_seg
, align
);
2062 /* Assume some objects may require alignment on some systems. */
2063 #if defined (TC_ALPHA) && ! defined (VMS)
2066 align
= ffs (temp
) - 1;
2067 if (temp
% (1 << align
))
2074 symbolP
= symbol_find_or_make (name
);
2078 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2079 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2080 #ifdef BFD_ASSEMBLER
2081 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2082 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2084 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2087 (S_GET_SEGMENT (symbolP
) == bss_seg
2088 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2092 subseg_set (bss_seg
, 1);
2095 frag_align (align
, 0, 0);
2097 /* Detach from old frag. */
2098 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2099 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2101 symbol_set_frag (symbolP
, frag_now
);
2102 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2103 (offsetT
) temp
, (char *) 0);
2106 S_SET_SEGMENT (symbolP
, bss_seg
);
2109 /* The symbol may already have been created with a preceding
2110 ".globl" directive -- be careful not to step on storage class
2111 in that case. Otherwise, set it to static. */
2112 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2114 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2116 #endif /* OBJ_COFF */
2119 S_SET_SIZE (symbolP
, temp
);
2123 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2125 subseg_set (current_seg
, current_subseg
);
2127 demand_empty_rest_of_line ();
2131 s_lcomm (needs_align
)
2134 s_lcomm_internal (needs_align
, 0);
2138 s_lcomm_bytes (needs_align
)
2141 s_lcomm_internal (needs_align
, 1);
2146 int ignore ATTRIBUTE_UNUSED
;
2148 register char *name
;
2152 register symbolS
*symbolP
;
2154 /* We permit ANY defined expression: BSD4.2 demands constants. */
2155 name
= input_line_pointer
;
2156 c
= get_symbol_end ();
2157 p
= input_line_pointer
;
2162 as_bad (_("expected symbol name"));
2163 discard_rest_of_line ();
2169 if (*input_line_pointer
!= ',')
2172 as_bad (_("expected comma after \"%s\""), name
);
2174 ignore_rest_of_line ();
2178 input_line_pointer
++;
2181 if (exp
.X_op
!= O_constant
2182 && exp
.X_op
!= O_register
)
2184 as_bad (_("bad expression"));
2185 ignore_rest_of_line ();
2190 symbolP
= symbol_find_or_make (name
);
2192 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2193 symbolP->sy_desc == 0) out of this test because coff doesn't have
2194 those fields, and I can't see when they'd ever be tripped. I
2195 don't think I understand why they were here so I may have
2196 introduced a bug. As recently as 1.37 didn't have this test
2197 anyway. xoxorich. */
2199 if (S_GET_SEGMENT (symbolP
) == undefined_section
2200 && S_GET_VALUE (symbolP
) == 0)
2202 /* The name might be an undefined .global symbol; be sure to
2203 keep the "external" bit. */
2204 S_SET_SEGMENT (symbolP
,
2205 (exp
.X_op
== O_constant
2208 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2212 as_bad (_("symbol `%s' is already defined"), name
);
2216 demand_empty_rest_of_line ();
2219 /* Read a line into an sb. */
2225 char quote1
, quote2
, inquote
;
2227 if (input_line_pointer
[-1] == '\n')
2228 bump_line_counters ();
2230 if (input_line_pointer
>= buffer_limit
)
2232 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2233 if (buffer_limit
== 0)
2237 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2238 code needs to be changed. */
2247 #ifdef LEX_IS_STRINGQUOTE
2253 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2254 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2256 if (inquote
== *input_line_pointer
)
2258 else if (inquote
== '\0')
2260 if (*input_line_pointer
== quote1
)
2262 else if (*input_line_pointer
== quote2
)
2266 sb_add_char (line
, *input_line_pointer
++);
2269 while (input_line_pointer
< buffer_limit
2270 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2272 if (input_line_pointer
[-1] == '\n')
2273 bump_line_counters ();
2274 ++input_line_pointer
;
2280 /* Define a macro. This is an interface to macro.c, which is shared
2281 between gas and gasp. */
2285 int ignore ATTRIBUTE_UNUSED
;
2294 as_where (&file
, &line
);
2297 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2298 sb_add_char (&s
, *input_line_pointer
++);
2301 if (line_label
!= NULL
)
2302 sb_add_string (&label
, S_GET_NAME (line_label
));
2304 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2306 as_bad_where (file
, line
, "%s", err
);
2309 if (line_label
!= NULL
)
2311 S_SET_SEGMENT (line_label
, undefined_section
);
2312 S_SET_VALUE (line_label
, 0);
2313 symbol_set_frag (line_label
, &zero_address_frag
);
2316 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2317 && hash_find (po_hash
, name
) != NULL
)
2320 && hash_find (po_hash
, name
+ 1) != NULL
))
2321 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2328 /* Handle the .mexit pseudo-op, which immediately exits a macro
2333 int ignore ATTRIBUTE_UNUSED
;
2335 cond_exit_macro (macro_nest
);
2336 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2339 /* Switch in and out of MRI mode. */
2343 int ignore ATTRIBUTE_UNUSED
;
2347 on
= get_absolute_expression ();
2348 old_flag
= flag_mri
;
2366 /* Operator precedence changes in m68k MRI mode, so we need to
2367 update the operator rankings. */
2368 expr_set_precedence ();
2370 #ifdef MRI_MODE_CHANGE
2372 MRI_MODE_CHANGE (on
);
2375 demand_empty_rest_of_line ();
2378 /* Handle changing the location counter. */
2381 do_org (segment
, exp
, fill
)
2386 if (segment
!= now_seg
&& segment
!= absolute_section
)
2387 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2389 if (now_seg
== absolute_section
)
2392 as_warn (_("ignoring fill value in absolute section"));
2393 if (exp
->X_op
!= O_constant
)
2395 as_bad (_("only constant offsets supported in absolute section"));
2396 exp
->X_add_number
= 0;
2398 abs_section_offset
= exp
->X_add_number
;
2403 symbolS
*sym
= exp
->X_add_symbol
;
2404 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2406 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2408 /* Handle complex expressions. */
2409 sym
= make_expr_symbol (exp
);
2413 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2420 int ignore ATTRIBUTE_UNUSED
;
2422 register segT segment
;
2424 register long temp_fill
;
2426 #ifdef md_flush_pending_output
2427 md_flush_pending_output ();
2430 /* The m68k MRI assembler has a different meaning for .org. It
2431 means to create an absolute section at a given address. We can't
2432 support that--use a linker script instead. */
2435 as_bad (_("MRI style ORG pseudo-op not supported"));
2436 ignore_rest_of_line ();
2440 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2441 thing as a sub-segment-relative origin. Any absolute origin is
2442 given a warning, then assumed to be segment-relative. Any
2443 segmented origin expression ("foo+42") had better be in the right
2444 segment or the .org is ignored.
2446 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2447 we never know sub-segment sizes when we are reading code. BSD
2448 will crash trying to emit negative numbers of filler bytes in
2449 certain .orgs. We don't crash, but see as-write for that code.
2451 Don't make frag if need_pass_2==1. */
2452 segment
= get_known_segmented_expression (&exp
);
2453 if (*input_line_pointer
== ',')
2455 input_line_pointer
++;
2456 temp_fill
= get_absolute_expression ();
2462 do_org (segment
, &exp
, temp_fill
);
2464 demand_empty_rest_of_line ();
2467 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2468 called by the obj-format routine which handles section changing
2469 when in MRI mode. It will create a new section, and return it. It
2470 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2471 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2472 flags will be set in the section. */
2476 char *type ATTRIBUTE_UNUSED
;
2486 name
= input_line_pointer
;
2487 if (!ISDIGIT (*name
))
2488 c
= get_symbol_end ();
2493 ++input_line_pointer
;
2495 while (ISDIGIT (*input_line_pointer
));
2497 c
= *input_line_pointer
;
2498 *input_line_pointer
= '\0';
2501 name
= xstrdup (name
);
2503 *input_line_pointer
= c
;
2505 seg
= subseg_new (name
, 0);
2507 if (*input_line_pointer
== ',')
2511 ++input_line_pointer
;
2512 align
= get_absolute_expression ();
2513 record_alignment (seg
, align
);
2517 if (*input_line_pointer
== ',')
2519 c
= *++input_line_pointer
;
2521 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2524 as_bad (_("unrecognized section type"));
2525 ++input_line_pointer
;
2527 #ifdef BFD_ASSEMBLER
2531 flags
= SEC_NO_FLAGS
;
2533 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2534 else if (*type
== 'D' || *type
== 'M')
2535 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2536 else if (*type
== 'R')
2537 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2538 if (flags
!= SEC_NO_FLAGS
)
2540 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2541 as_warn (_("error setting flags for \"%s\": %s"),
2542 bfd_section_name (stdoutput
, seg
),
2543 bfd_errmsg (bfd_get_error ()));
2549 /* Ignore the HP type. */
2550 if (*input_line_pointer
== ',')
2551 input_line_pointer
+= 2;
2553 demand_empty_rest_of_line ();
2555 #else /* ! TC_M68K */
2564 name
= input_line_pointer
;
2565 c
= get_symbol_end ();
2567 name
= xstrdup (name
);
2569 *input_line_pointer
= c
;
2571 seg
= subseg_new (name
, 0);
2573 if (*input_line_pointer
!= ',')
2579 ++input_line_pointer
;
2581 sectype
= input_line_pointer
;
2582 c
= get_symbol_end ();
2583 if (*sectype
== '\0')
2585 else if (strcasecmp (sectype
, "text") == 0)
2587 else if (strcasecmp (sectype
, "data") == 0)
2589 else if (strcasecmp (sectype
, "romdata") == 0)
2592 as_warn (_("unrecognized section type `%s'"), sectype
);
2593 *input_line_pointer
= c
;
2596 if (*input_line_pointer
== ',')
2600 ++input_line_pointer
;
2602 seccmd
= input_line_pointer
;
2603 c
= get_symbol_end ();
2604 if (strcasecmp (seccmd
, "absolute") == 0)
2606 as_bad (_("absolute sections are not supported"));
2607 *input_line_pointer
= c
;
2608 ignore_rest_of_line ();
2611 else if (strcasecmp (seccmd
, "align") == 0)
2615 *input_line_pointer
= c
;
2616 align
= get_absolute_expression ();
2617 record_alignment (seg
, align
);
2621 as_warn (_("unrecognized section command `%s'"), seccmd
);
2622 *input_line_pointer
= c
;
2626 demand_empty_rest_of_line ();
2628 #else /* ! TC_I960 */
2629 /* The MRI assembler seems to use different forms of .sect for
2630 different targets. */
2631 as_bad ("MRI mode not supported for this target");
2632 ignore_rest_of_line ();
2633 #endif /* ! TC_I960 */
2634 #endif /* ! TC_M68K */
2637 /* Handle the .print pseudo-op. */
2641 int ignore ATTRIBUTE_UNUSED
;
2646 s
= demand_copy_C_string (&len
);
2648 demand_empty_rest_of_line ();
2651 /* Handle the .purgem pseudo-op. */
2655 int ignore ATTRIBUTE_UNUSED
;
2657 if (is_it_end_of_statement ())
2659 demand_empty_rest_of_line ();
2669 name
= input_line_pointer
;
2670 c
= get_symbol_end ();
2671 delete_macro (name
);
2672 *input_line_pointer
= c
;
2675 while (*input_line_pointer
++ == ',');
2677 --input_line_pointer
;
2678 demand_empty_rest_of_line ();
2681 /* Handle the .rept pseudo-op. */
2685 int ignore ATTRIBUTE_UNUSED
;
2689 count
= get_absolute_expression ();
2691 do_repeat (count
, "REPT", "ENDR");
2694 /* This function provides a generic repeat block implementation. It allows
2695 different directives to be used as the start/end keys. */
2698 do_repeat (count
, start
, end
)
2707 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2709 as_bad (_("%s without %s"), start
, end
);
2715 sb_add_sb (&many
, &one
);
2719 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2721 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2724 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2725 input buffers to skip. Assumes that conditionals preceding the loop end
2726 are properly nested.
2728 This function makes it easier to implement a premature "break" out of the
2729 loop. The EXTRA arg accounts for other buffers we might have inserted,
2730 such as line substitutions. */
2736 cond_exit_macro (macro_nest
);
2737 while (extra
-- >= 0)
2738 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2741 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2742 this is .equiv, and it is an error if the symbol is already
2749 register char *name
;
2750 register char delim
;
2751 register char *end_name
;
2752 register symbolS
*symbolP
;
2754 /* Especial apologies for the random logic:
2755 this just grew, and could be parsed much more simply!
2757 name
= input_line_pointer
;
2758 delim
= get_symbol_end ();
2759 end_name
= input_line_pointer
;
2762 if (name
== end_name
)
2764 as_bad (_("expected symbol name"));
2765 discard_rest_of_line ();
2771 if (*input_line_pointer
!= ',')
2774 as_bad (_("expected comma after \"%s\""), name
);
2776 ignore_rest_of_line ();
2780 input_line_pointer
++;
2783 if (name
[0] == '.' && name
[1] == '\0')
2785 /* Turn '. = mumble' into a .org mumble. */
2786 register segT segment
;
2789 segment
= get_known_segmented_expression (&exp
);
2792 do_org (segment
, &exp
, 0);
2798 if ((symbolP
= symbol_find (name
)) == NULL
2799 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2802 /* When doing symbol listings, play games with dummy fragments living
2803 outside the normal fragment chain to record the file and line info
2805 if (listing
& LISTING_SYMBOLS
)
2807 extern struct list_info_struct
*listing_tail
;
2808 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2809 memset (dummy_frag
, 0, sizeof (fragS
));
2810 dummy_frag
->fr_type
= rs_fill
;
2811 dummy_frag
->line
= listing_tail
;
2812 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2813 dummy_frag
->fr_symbol
= symbolP
;
2817 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2820 /* "set" symbols are local unless otherwise specified. */
2821 SF_SET_LOCAL (symbolP
);
2822 #endif /* OBJ_COFF */
2825 symbol_table_insert (symbolP
);
2830 && S_IS_DEFINED (symbolP
)
2831 && S_GET_SEGMENT (symbolP
) != reg_section
)
2832 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2834 pseudo_set (symbolP
);
2835 demand_empty_rest_of_line ();
2849 #ifdef md_flush_pending_output
2850 md_flush_pending_output ();
2854 stop
= mri_comment_field (&stopc
);
2856 /* In m68k MRI mode, we need to align to a word boundary, unless
2858 if (flag_m68k_mri
&& mult
> 1)
2860 if (now_seg
== absolute_section
)
2862 abs_section_offset
+= abs_section_offset
& 1;
2863 if (line_label
!= NULL
)
2864 S_SET_VALUE (line_label
, abs_section_offset
);
2866 else if (mri_common_symbol
!= NULL
)
2870 val
= S_GET_VALUE (mri_common_symbol
);
2873 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2874 if (line_label
!= NULL
)
2876 expressionS
*symexp
;
2878 symexp
= symbol_get_value_expression (line_label
);
2879 know (symexp
->X_op
== O_symbol
);
2880 know (symexp
->X_add_symbol
== mri_common_symbol
);
2881 symexp
->X_add_number
+= 1;
2887 do_align (1, (char *) NULL
, 0, 0);
2888 if (line_label
!= NULL
)
2890 symbol_set_frag (line_label
, frag_now
);
2891 S_SET_VALUE (line_label
, frag_now_fix ());
2901 if (*input_line_pointer
== ',')
2903 ++input_line_pointer
;
2908 val
.X_op
= O_constant
;
2909 val
.X_add_number
= 0;
2912 if (val
.X_op
!= O_constant
2913 || val
.X_add_number
< - 0x80
2914 || val
.X_add_number
> 0xff
2915 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2917 if (exp
.X_op
!= O_constant
)
2918 as_bad (_("unsupported variable size or fill value"));
2925 bytes
= mult
* exp
.X_add_number
;
2926 for (i
= 0; i
< exp
.X_add_number
; i
++)
2927 emit_expr (&val
, mult
);
2932 if (exp
.X_op
== O_constant
)
2936 repeat
= exp
.X_add_number
;
2943 as_warn (_(".space repeat count is zero, ignored"));
2944 else if (repeat
< 0)
2945 as_warn (_(".space repeat count is negative, ignored"));
2949 /* If we are in the absolute section, just bump the offset. */
2950 if (now_seg
== absolute_section
)
2952 abs_section_offset
+= repeat
;
2956 /* If we are secretly in an MRI common section, then
2957 creating space just increases the size of the common
2959 if (mri_common_symbol
!= NULL
)
2961 S_SET_VALUE (mri_common_symbol
,
2962 S_GET_VALUE (mri_common_symbol
) + repeat
);
2967 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2968 (offsetT
) repeat
, (char *) 0);
2972 if (now_seg
== absolute_section
)
2974 as_bad (_("space allocation too complex in absolute section"));
2975 subseg_set (text_section
, 0);
2978 if (mri_common_symbol
!= NULL
)
2980 as_bad (_("space allocation too complex in common section"));
2981 mri_common_symbol
= NULL
;
2985 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2986 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2990 *p
= val
.X_add_number
;
2995 /* In MRI mode, after an odd number of bytes, we must align to an
2996 even word boundary, unless the next instruction is a dc.b, ds.b
2998 if (flag_mri
&& (bytes
& 1) != 0)
2999 mri_pending_align
= 1;
3001 demand_empty_rest_of_line ();
3004 mri_comment_end (stop
, stopc
);
3007 /* This is like s_space, but the value is a floating point number with
3008 the given precision. This is for the MRI dcb.s pseudo-op and
3012 s_float_space (float_type
)
3017 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3022 stop
= mri_comment_field (&stopc
);
3024 count
= get_absolute_expression ();
3027 if (*input_line_pointer
!= ',')
3029 as_bad (_("missing value"));
3030 ignore_rest_of_line ();
3032 mri_comment_end (stop
, stopc
);
3036 ++input_line_pointer
;
3040 /* Skip any 0{letter} that may be present. Don't even check if the
3041 * letter is legal. */
3042 if (input_line_pointer
[0] == '0'
3043 && ISALPHA (input_line_pointer
[1]))
3044 input_line_pointer
+= 2;
3046 /* Accept :xxxx, where the x's are hex digits, for a floating point
3047 with the exact digits specified. */
3048 if (input_line_pointer
[0] == ':')
3050 flen
= hex_float (float_type
, temp
);
3053 ignore_rest_of_line ();
3055 mri_comment_end (stop
, stopc
);
3063 err
= md_atof (float_type
, temp
, &flen
);
3064 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3068 as_bad (_("bad floating literal: %s"), err
);
3069 ignore_rest_of_line ();
3071 mri_comment_end (stop
, stopc
);
3076 while (--count
>= 0)
3080 p
= frag_more (flen
);
3081 memcpy (p
, temp
, (unsigned int) flen
);
3084 demand_empty_rest_of_line ();
3087 mri_comment_end (stop
, stopc
);
3090 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3094 int ignore ATTRIBUTE_UNUSED
;
3100 stop
= mri_comment_field (&stopc
);
3101 abs_section_offset
= get_absolute_expression ();
3102 subseg_set (absolute_section
, 0);
3103 demand_empty_rest_of_line ();
3105 mri_comment_end (stop
, stopc
);
3110 int ignore ATTRIBUTE_UNUSED
;
3114 temp
= get_absolute_expression ();
3115 subseg_set (text_section
, (subsegT
) temp
);
3116 demand_empty_rest_of_line ();
3118 const_flag
&= ~IN_DEFAULT_SECTION
;
3123 demand_empty_rest_of_line ()
3126 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3127 input_line_pointer
++;
3129 ignore_rest_of_line ();
3131 /* Return having already swallowed end-of-line. */
3135 ignore_rest_of_line ()
3137 /* For suspect lines: gives warning. */
3138 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3140 if (ISPRINT (*input_line_pointer
))
3141 as_warn (_("rest of line ignored; first ignored character is `%c'"),
3142 *input_line_pointer
);
3144 as_warn (_("rest of line ignored; first ignored character valued 0x%x"),
3145 *input_line_pointer
);
3147 while (input_line_pointer
< buffer_limit
3148 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3149 input_line_pointer
++;
3152 input_line_pointer
++;
3154 /* Return pointing just after end-of-line. */
3155 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3159 discard_rest_of_line ()
3161 while (input_line_pointer
< buffer_limit
3162 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3163 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]]);
3171 /* In: Pointer to a symbol.
3172 Input_line_pointer->expression.
3174 Out: Input_line_pointer->just after any whitespace after expression.
3175 Tried to set symbol to value of expression.
3176 Will change symbols type, value, and frag; */
3179 pseudo_set (symbolP
)
3183 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3185 #endif /* OBJ_AOUT or OBJ_BOUT */
3187 know (symbolP
); /* NULL pointer is logic error. */
3188 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3189 ext
= S_IS_EXTERNAL (symbolP
);
3190 #endif /* OBJ_AOUT or OBJ_BOUT */
3192 (void) expression (&exp
);
3194 if (exp
.X_op
== O_illegal
)
3195 as_bad (_("illegal expression"));
3196 else if (exp
.X_op
== O_absent
)
3197 as_bad (_("missing expression"));
3198 else if (exp
.X_op
== O_big
)
3200 if (exp
.X_add_number
> 0)
3201 as_bad (_("bignum invalid"));
3203 as_bad (_("floating point number invalid"));
3205 else if (exp
.X_op
== O_subtract
3206 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3207 == S_GET_SEGMENT (exp
.X_op_symbol
))
3208 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3209 && (symbol_get_frag (exp
.X_add_symbol
)
3210 == symbol_get_frag (exp
.X_op_symbol
)))
3212 exp
.X_op
= O_constant
;
3213 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3214 - S_GET_VALUE (exp
.X_op_symbol
));
3222 exp
.X_add_number
= 0;
3225 S_SET_SEGMENT (symbolP
, absolute_section
);
3226 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3228 S_SET_EXTERNAL (symbolP
);
3230 S_CLEAR_EXTERNAL (symbolP
);
3231 #endif /* OBJ_AOUT or OBJ_BOUT */
3232 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3233 if (exp
.X_op
!= O_constant
)
3234 symbol_set_frag (symbolP
, &zero_address_frag
);
3238 S_SET_SEGMENT (symbolP
, reg_section
);
3239 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3240 symbol_set_frag (symbolP
, &zero_address_frag
);
3244 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3245 || exp
.X_add_number
!= 0)
3246 symbol_set_value_expression (symbolP
, &exp
);
3247 else if (symbol_section_p (symbolP
))
3248 as_bad ("attempt to set value of section symbol");
3251 symbolS
*s
= exp
.X_add_symbol
;
3253 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3254 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3256 S_SET_EXTERNAL (symbolP
);
3258 S_CLEAR_EXTERNAL (symbolP
);
3259 #endif /* OBJ_AOUT or OBJ_BOUT */
3260 S_SET_VALUE (symbolP
,
3261 exp
.X_add_number
+ S_GET_VALUE (s
));
3262 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3263 copy_symbol_attributes (symbolP
, s
);
3268 /* The value is some complex expression.
3269 FIXME: Should we set the segment to anything? */
3270 symbol_set_value_expression (symbolP
, &exp
);
3277 CONStruct more frag of .bytes, or .words etc.
3278 Should need_pass_2 be 1 then emit no frag(s).
3279 This understands EXPRESSIONS.
3283 This has a split personality. We use expression() to read the
3284 value. We can detect if the value won't fit in a byte or word.
3285 But we can't detect if expression() discarded significant digits
3286 in the case of a long. Not worth the crocks required to fix it. */
3288 /* Select a parser for cons expressions. */
3290 /* Some targets need to parse the expression in various fancy ways.
3291 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3292 (for example, the HPPA does this). Otherwise, you can define
3293 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3294 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3295 are defined, which is the normal case, then only simple expressions
3300 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3303 #ifndef TC_PARSE_CONS_EXPRESSION
3304 #ifdef BITFIELD_CONS_EXPRESSIONS
3305 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3307 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3309 #ifdef REPEAT_CONS_EXPRESSIONS
3310 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3312 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3315 /* If we haven't gotten one yet, just call expression. */
3316 #ifndef TC_PARSE_CONS_EXPRESSION
3317 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3321 /* Worker to do .byte etc statements.
3322 Clobbers input_line_pointer and checks end-of-line. */
3325 cons_worker (nbytes
, rva
)
3326 register int nbytes
; /* 1=.byte, 2=.word, 4=.long. */
3334 #ifdef md_flush_pending_output
3335 md_flush_pending_output ();
3339 stop
= mri_comment_field (&stopc
);
3341 if (is_it_end_of_statement ())
3343 demand_empty_rest_of_line ();
3345 mri_comment_end (stop
, stopc
);
3349 #ifdef md_cons_align
3350 md_cons_align (nbytes
);
3358 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3361 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3365 if (exp
.X_op
== O_symbol
)
3366 exp
.X_op
= O_symbol_rva
;
3368 as_fatal (_("rva without symbol"));
3370 emit_expr (&exp
, (unsigned int) nbytes
);
3373 while (*input_line_pointer
++ == ',');
3375 /* In MRI mode, after an odd number of bytes, we must align to an
3376 even word boundary, unless the next instruction is a dc.b, ds.b
3378 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3379 mri_pending_align
= 1;
3381 input_line_pointer
--; /* Put terminator back into stream. */
3383 demand_empty_rest_of_line ();
3386 mri_comment_end (stop
, stopc
);
3393 cons_worker (size
, 0);
3400 cons_worker (size
, 1);
3403 /* Put the contents of expression EXP into the object file using
3404 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3407 emit_expr (exp
, nbytes
)
3409 unsigned int nbytes
;
3413 valueT extra_digit
= 0;
3415 /* Don't do anything if we are going to make another pass. */
3421 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3422 appear as a four byte positive constant in the .line section,
3423 followed by a 2 byte 0xffff. Look for that case here. */
3425 static int dwarf_line
= -1;
3427 if (strcmp (segment_name (now_seg
), ".line") != 0)
3429 else if (dwarf_line
>= 0
3431 && exp
->X_op
== O_constant
3432 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3433 listing_source_line ((unsigned int) dwarf_line
);
3434 else if (nbytes
== 4
3435 && exp
->X_op
== O_constant
3436 && exp
->X_add_number
>= 0)
3437 dwarf_line
= exp
->X_add_number
;
3442 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3443 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3444 AT_sibling (0x12) followed by a four byte address of the sibling
3445 followed by a 2 byte AT_name (0x38) followed by the name of the
3446 file. We look for that case here. */
3448 static int dwarf_file
= 0;
3450 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3452 else if (dwarf_file
== 0
3454 && exp
->X_op
== O_constant
3455 && exp
->X_add_number
== 0x11)
3457 else if (dwarf_file
== 1
3459 && exp
->X_op
== O_constant
3460 && exp
->X_add_number
== 0x12)
3462 else if (dwarf_file
== 2
3465 else if (dwarf_file
== 3
3467 && exp
->X_op
== O_constant
3468 && exp
->X_add_number
== 0x38)
3473 /* The variable dwarf_file_string tells stringer that the string
3474 may be the name of the source file. */
3475 if (dwarf_file
== 4)
3476 dwarf_file_string
= 1;
3478 dwarf_file_string
= 0;
3483 if (check_eh_frame (exp
, &nbytes
))
3488 /* Allow `.word 0' in the absolute section. */
3489 if (now_seg
== absolute_section
)
3491 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3492 as_bad (_("attempt to store value in absolute section"));
3493 abs_section_offset
+= nbytes
;
3497 /* Handle a negative bignum. */
3499 && exp
->X_add_number
== 0
3500 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3501 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3504 unsigned long carry
;
3506 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3508 /* Negate the bignum: one's complement each digit and add 1. */
3510 for (i
= 0; i
< exp
->X_add_number
; i
++)
3514 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3517 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3518 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3521 /* We can ignore any carry out, because it will be handled by
3522 extra_digit if it is needed. */
3524 extra_digit
= (valueT
) -1;
3528 if (op
== O_absent
|| op
== O_illegal
)
3530 as_warn (_("zero assumed for missing expression"));
3531 exp
->X_add_number
= 0;
3534 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3536 as_bad (_("floating point number invalid"));
3537 exp
->X_add_number
= 0;
3540 else if (op
== O_register
)
3542 as_warn (_("register value used as expression"));
3546 p
= frag_more ((int) nbytes
);
3548 #ifndef WORKING_DOT_WORD
3549 /* If we have the difference of two symbols in a word, save it on
3550 the broken_words list. See the code in write.c. */
3551 if (op
== O_subtract
&& nbytes
== 2)
3553 struct broken_word
*x
;
3555 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3556 x
->next_broken_word
= broken_words
;
3559 x
->subseg
= now_subseg
;
3561 x
->word_goes_here
= p
;
3563 x
->add
= exp
->X_add_symbol
;
3564 x
->sub
= exp
->X_op_symbol
;
3565 x
->addnum
= exp
->X_add_number
;
3572 /* If we have an integer, but the number of bytes is too large to
3573 pass to md_number_to_chars, handle it as a bignum. */
3574 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3579 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3580 extra_digit
= (valueT
) -1;
3581 val
= (valueT
) exp
->X_add_number
;
3585 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3586 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3590 op
= exp
->X_op
= O_big
;
3591 exp
->X_add_number
= gencnt
;
3594 if (op
== O_constant
)
3596 register valueT get
;
3597 register valueT use
;
3598 register valueT mask
;
3600 register valueT unmask
;
3602 /* JF << of >= number of bits in the object is undefined. In
3603 particular SPARC (Sun 4) has problems. */
3604 if (nbytes
>= sizeof (valueT
))
3607 if (nbytes
> sizeof (valueT
))
3610 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3614 /* Don't store these bits. */
3615 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3616 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3619 unmask
= ~mask
; /* Do store these bits. */
3622 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3623 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3626 get
= exp
->X_add_number
;
3628 if ((get
& mask
) != 0
3629 && ((get
& mask
) != mask
3630 || (get
& hibit
) == 0))
3631 { /* Leading bits contain both 0s & 1s. */
3632 as_warn (_("value 0x%lx truncated to 0x%lx"),
3633 (unsigned long) get
, (unsigned long) use
);
3635 /* Put bytes in right order. */
3636 md_number_to_chars (p
, use
, (int) nbytes
);
3638 else if (op
== O_big
)
3641 LITTLENUM_TYPE
*nums
;
3643 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3645 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3648 as_warn (_("bignum truncated to %d bytes"), nbytes
);
3652 if (target_big_endian
)
3654 while (nbytes
> size
)
3656 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3657 nbytes
-= CHARS_PER_LITTLENUM
;
3658 p
+= CHARS_PER_LITTLENUM
;
3661 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3665 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3666 size
-= CHARS_PER_LITTLENUM
;
3667 p
+= CHARS_PER_LITTLENUM
;
3672 nums
= generic_bignum
;
3675 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3677 size
-= CHARS_PER_LITTLENUM
;
3678 p
+= CHARS_PER_LITTLENUM
;
3679 nbytes
-= CHARS_PER_LITTLENUM
;
3684 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3685 nbytes
-= CHARS_PER_LITTLENUM
;
3686 p
+= CHARS_PER_LITTLENUM
;
3692 memset (p
, 0, nbytes
);
3694 /* Now we need to generate a fixS to record the symbol value.
3695 This is easy for BFD. For other targets it can be more
3696 complex. For very complex cases (currently, the HPPA and
3697 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3698 want. For simpler cases, you can define TC_CONS_RELOC to be
3699 the name of the reloc code that should be stored in the fixS.
3700 If neither is defined, the code uses NO_RELOC if it is
3701 defined, and otherwise uses 0. */
3703 #ifdef BFD_ASSEMBLER
3704 #ifdef TC_CONS_FIX_NEW
3705 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3708 bfd_reloc_code_real_type r
;
3725 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3729 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3734 #ifdef TC_CONS_FIX_NEW
3735 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3737 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3738 it is defined, otherwise use NO_RELOC if it is defined,
3740 #ifndef TC_CONS_RELOC
3742 #define TC_CONS_RELOC NO_RELOC
3744 #define TC_CONS_RELOC 0
3747 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3749 #endif /* TC_CONS_FIX_NEW */
3750 #endif /* BFD_ASSEMBLER */
3754 #ifdef BITFIELD_CONS_EXPRESSIONS
3756 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3757 w:x,y:z, where w and y are bitwidths and x and y are values. They
3758 then pack them all together. We do a little better in that we allow
3759 them in words, longs, etc. and we'll pack them in target byte order
3762 The rules are: pack least significat bit first, if a field doesn't
3763 entirely fit, put it in the next unit. Overflowing the bitfield is
3764 explicitly *not* even a warning. The bitwidth should be considered
3767 To use this function the tc-XXX.h file should define
3768 BITFIELD_CONS_EXPRESSIONS. */
3771 parse_bitfield_cons (exp
, nbytes
)
3773 unsigned int nbytes
;
3775 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3776 char *hold
= input_line_pointer
;
3778 (void) expression (exp
);
3780 if (*input_line_pointer
== ':')
3787 unsigned long width
;
3789 if (*input_line_pointer
!= ':')
3791 input_line_pointer
= hold
;
3793 } /* Next piece is not a bitfield. */
3795 /* In the general case, we can't allow
3796 full expressions with symbol
3797 differences and such. The relocation
3798 entries for symbols not defined in this
3799 assembly would require arbitrary field
3800 widths, positions, and masks which most
3801 of our current object formats don't
3804 In the specific case where a symbol
3805 *is* defined in this assembly, we
3806 *could* build fixups and track it, but
3807 this could lead to confusion for the
3808 backends. I'm lazy. I'll take any
3809 SEG_ABSOLUTE. I think that means that
3810 you can use a previous .set or
3811 .equ type symbol. xoxorich. */
3813 if (exp
->X_op
== O_absent
)
3815 as_warn (_("using a bit field width of zero"));
3816 exp
->X_add_number
= 0;
3817 exp
->X_op
= O_constant
;
3818 } /* Implied zero width bitfield. */
3820 if (exp
->X_op
!= O_constant
)
3822 *input_line_pointer
= '\0';
3823 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3824 *input_line_pointer
= ':';
3825 demand_empty_rest_of_line ();
3827 } /* Too complex. */
3829 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3831 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3832 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3833 width
= BITS_PER_CHAR
* nbytes
;
3836 if (width
> bits_available
)
3838 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3839 input_line_pointer
= hold
;
3840 exp
->X_add_number
= value
;
3845 hold
= ++input_line_pointer
;
3847 (void) expression (exp
);
3848 if (exp
->X_op
!= O_constant
)
3850 char cache
= *input_line_pointer
;
3852 *input_line_pointer
= '\0';
3853 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3854 *input_line_pointer
= cache
;
3855 demand_empty_rest_of_line ();
3857 } /* Too complex. */
3859 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3860 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3862 if ((bits_available
-= width
) == 0
3863 || is_it_end_of_statement ()
3864 || *input_line_pointer
!= ',')
3867 } /* All the bitfields we're gonna get. */
3869 hold
= ++input_line_pointer
;
3870 (void) expression (exp
);
3873 exp
->X_add_number
= value
;
3874 exp
->X_op
= O_constant
;
3875 exp
->X_unsigned
= 1;
3879 #endif /* BITFIELD_CONS_EXPRESSIONS */
3881 /* Handle an MRI style string expression. */
3885 parse_mri_cons (exp
, nbytes
)
3887 unsigned int nbytes
;
3889 if (*input_line_pointer
!= '\''
3890 && (input_line_pointer
[1] != '\''
3891 || (*input_line_pointer
!= 'A'
3892 && *input_line_pointer
!= 'E')))
3893 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3897 unsigned int result
= 0;
3899 /* An MRI style string. Cut into as many bytes as will fit into
3900 a nbyte chunk, left justify if necessary, and separate with
3901 commas so we can try again later. */
3902 if (*input_line_pointer
== 'A')
3903 ++input_line_pointer
;
3904 else if (*input_line_pointer
== 'E')
3906 as_bad (_("EBCDIC constants are not supported"));
3907 ++input_line_pointer
;
3910 input_line_pointer
++;
3911 for (scan
= 0; scan
< nbytes
; scan
++)
3913 if (*input_line_pointer
== '\'')
3915 if (input_line_pointer
[1] == '\'')
3917 input_line_pointer
++;
3922 result
= (result
<< 8) | (*input_line_pointer
++);
3926 while (scan
< nbytes
)
3932 /* Create correct expression. */
3933 exp
->X_op
= O_constant
;
3934 exp
->X_add_number
= result
;
3936 /* Fake it so that we can read the next char too. */
3937 if (input_line_pointer
[0] != '\'' ||
3938 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3940 input_line_pointer
-= 2;
3941 input_line_pointer
[0] = ',';
3942 input_line_pointer
[1] = '\'';
3945 input_line_pointer
++;
3948 #endif /* TC_M68K */
3950 #ifdef REPEAT_CONS_EXPRESSIONS
3952 /* Parse a repeat expression for cons. This is used by the MIPS
3953 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3954 object file COUNT times.
3956 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3959 parse_repeat_cons (exp
, nbytes
)
3961 unsigned int nbytes
;
3968 if (*input_line_pointer
!= ':')
3970 /* No repeat count. */
3974 ++input_line_pointer
;
3975 expression (&count
);
3976 if (count
.X_op
!= O_constant
3977 || count
.X_add_number
<= 0)
3979 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
3983 /* The cons function is going to output this expression once. So we
3984 output it count - 1 times. */
3985 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3986 emit_expr (exp
, nbytes
);
3989 #endif /* REPEAT_CONS_EXPRESSIONS */
3991 /* Parse a floating point number represented as a hex constant. This
3992 permits users to specify the exact bits they want in the floating
3996 hex_float (float_type
, bytes
)
4030 as_bad (_("unknown floating type type '%c'"), float_type
);
4034 /* It would be nice if we could go through expression to parse the
4035 hex constant, but if we get a bignum it's a pain to sort it into
4036 the buffer correctly. */
4038 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4042 /* The MRI assembler accepts arbitrary underscores strewn about
4043 through the hex constant, so we ignore them as well. */
4044 if (*input_line_pointer
== '_')
4046 ++input_line_pointer
;
4052 as_warn (_("floating point constant too large"));
4055 d
= hex_value (*input_line_pointer
) << 4;
4056 ++input_line_pointer
;
4057 while (*input_line_pointer
== '_')
4058 ++input_line_pointer
;
4059 if (hex_p (*input_line_pointer
))
4061 d
+= hex_value (*input_line_pointer
);
4062 ++input_line_pointer
;
4064 if (target_big_endian
)
4067 bytes
[length
- i
- 1] = d
;
4073 if (target_big_endian
)
4074 memset (bytes
+ i
, 0, length
- i
);
4076 memset (bytes
, 0, length
- i
);
4084 CONStruct some more frag chars of .floats .ffloats etc.
4085 Makes 0 or more new frags.
4086 If need_pass_2 == 1, no frags are emitted.
4087 This understands only floating literals, not expressions. Sorry.
4089 A floating constant is defined by atof_generic(), except it is preceded
4090 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4091 reading, I decided to be incompatible. This always tries to give you
4092 rounded bits to the precision of the pseudo-op. Former AS did premature
4093 truncatation, restored noisy bits instead of trailing 0s AND gave you
4094 a choice of 2 flavours of noise according to which of 2 floating-point
4095 scanners you directed AS to use.
4097 In: input_line_pointer->whitespace before, or '0' of flonum. */
4100 float_cons (float_type
)
4101 /* Clobbers input_line-pointer, checks end-of-line. */
4102 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4105 int length
; /* Number of chars in an object. */
4106 register char *err
; /* Error from scanning floating literal. */
4107 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4109 if (is_it_end_of_statement ())
4111 demand_empty_rest_of_line ();
4115 #ifdef md_flush_pending_output
4116 md_flush_pending_output ();
4121 /* input_line_pointer->1st char of a flonum (we hope!). */
4124 /* Skip any 0{letter} that may be present. Don't even check if the
4125 letter is legal. Someone may invent a "z" format and this routine
4126 has no use for such information. Lusers beware: you get
4127 diagnostics if your input is ill-conditioned. */
4128 if (input_line_pointer
[0] == '0'
4129 && ISALPHA (input_line_pointer
[1]))
4130 input_line_pointer
+= 2;
4132 /* Accept :xxxx, where the x's are hex digits, for a floating
4133 point with the exact digits specified. */
4134 if (input_line_pointer
[0] == ':')
4136 ++input_line_pointer
;
4137 length
= hex_float (float_type
, temp
);
4140 ignore_rest_of_line ();
4146 err
= md_atof (float_type
, temp
, &length
);
4147 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4151 as_bad (_("bad floating literal: %s"), err
);
4152 ignore_rest_of_line ();
4163 #ifdef REPEAT_CONS_EXPRESSIONS
4164 if (*input_line_pointer
== ':')
4166 expressionS count_exp
;
4168 ++input_line_pointer
;
4169 expression (&count_exp
);
4171 if (count_exp
.X_op
!= O_constant
4172 || count_exp
.X_add_number
<= 0)
4173 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4175 count
= count_exp
.X_add_number
;
4179 while (--count
>= 0)
4181 p
= frag_more (length
);
4182 memcpy (p
, temp
, (unsigned int) length
);
4187 while (*input_line_pointer
++ == ',');
4189 /* Put terminator back into stream. */
4190 --input_line_pointer
;
4191 demand_empty_rest_of_line ();
4194 /* Return the size of a LEB128 value. */
4197 sizeof_sleb128 (value
)
4200 register int size
= 0;
4201 register unsigned byte
;
4205 byte
= (value
& 0x7f);
4206 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4207 Fortunately, we can structure things so that the extra work reduces
4208 to a noop on systems that do things "properly". */
4209 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4212 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4213 || ((value
== -1) && ((byte
& 0x40) != 0))));
4219 sizeof_uleb128 (value
)
4222 register int size
= 0;
4223 register unsigned byte
;
4227 byte
= (value
& 0x7f);
4237 sizeof_leb128 (value
, sign
)
4242 return sizeof_sleb128 ((offsetT
) value
);
4244 return sizeof_uleb128 (value
);
4247 /* Output a LEB128 value. */
4250 output_sleb128 (p
, value
)
4254 register char *orig
= p
;
4259 unsigned byte
= (value
& 0x7f);
4261 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4262 Fortunately, we can structure things so that the extra work reduces
4263 to a noop on systems that do things "properly". */
4264 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4266 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4267 || ((value
== -1) && ((byte
& 0x40) != 0))));
4279 output_uleb128 (p
, value
)
4287 unsigned byte
= (value
& 0x7f);
4290 /* More bytes to follow. */
4301 output_leb128 (p
, value
, sign
)
4307 return output_sleb128 (p
, (offsetT
) value
);
4309 return output_uleb128 (p
, value
);
4312 /* Do the same for bignums. We combine sizeof with output here in that
4313 we don't output for NULL values of P. It isn't really as critical as
4314 for "normal" values that this be streamlined. */
4317 output_big_sleb128 (p
, bignum
, size
)
4319 LITTLENUM_TYPE
*bignum
;
4327 /* Strip leading sign extensions off the bignum. */
4328 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4333 if (loaded
< 7 && size
> 0)
4335 val
|= (*bignum
<< loaded
);
4336 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4347 if ((val
== 0 && (byte
& 0x40) == 0)
4348 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4349 && (byte
& 0x40) != 0))
4357 while (byte
& 0x80);
4363 output_big_uleb128 (p
, bignum
, size
)
4365 LITTLENUM_TYPE
*bignum
;
4373 /* Strip leading zeros off the bignum. */
4374 /* XXX: Is this needed? */
4375 while (size
> 0 && bignum
[size
- 1] == 0)
4380 if (loaded
< 7 && size
> 0)
4382 val
|= (*bignum
<< loaded
);
4383 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4392 if (size
> 0 || val
)
4399 while (byte
& 0x80);
4405 output_big_leb128 (p
, bignum
, size
, sign
)
4407 LITTLENUM_TYPE
*bignum
;
4411 return output_big_sleb128 (p
, bignum
, size
);
4413 return output_big_uleb128 (p
, bignum
, size
);
4416 /* Generate the appropriate fragments for a given expression to emit a
4420 emit_leb128_expr (exp
, sign
)
4424 operatorT op
= exp
->X_op
;
4427 if (op
== O_absent
|| op
== O_illegal
)
4429 as_warn (_("zero assumed for missing expression"));
4430 exp
->X_add_number
= 0;
4433 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4435 as_bad (_("floating point number invalid"));
4436 exp
->X_add_number
= 0;
4439 else if (op
== O_register
)
4441 as_warn (_("register value used as expression"));
4445 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
4446 a signal that this is leb128 data. It shouldn't optimize this away. */
4448 if (check_eh_frame (exp
, &nbytes
))
4451 /* Let the backend know that subsequent data may be byte aligned. */
4452 #ifdef md_cons_align
4456 if (op
== O_constant
)
4458 /* If we've got a constant, emit the thing directly right now. */
4460 valueT value
= exp
->X_add_number
;
4464 size
= sizeof_leb128 (value
, sign
);
4465 p
= frag_more (size
);
4466 output_leb128 (p
, value
, sign
);
4468 else if (op
== O_big
)
4470 /* O_big is a different sort of constant. */
4475 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4476 p
= frag_more (size
);
4477 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4481 /* Otherwise, we have to create a variable sized fragment and
4482 resolve things later. */
4484 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4485 make_expr_symbol (exp
), 0, (char *) NULL
);
4489 /* Parse the .sleb128 and .uleb128 pseudos. */
4500 emit_leb128_expr (&exp
, sign
);
4502 while (*input_line_pointer
++ == ',');
4504 input_line_pointer
--;
4505 demand_empty_rest_of_line ();
4508 /* We read 0 or more ',' separated, double-quoted strings.
4509 Caller should have checked need_pass_2 is FALSE because we don't
4513 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4514 /* Checks end-of-line. */
4515 register int append_zero
; /* 0: don't append '\0', else 1. */
4517 register unsigned int c
;
4520 #ifdef md_flush_pending_output
4521 md_flush_pending_output ();
4524 /* The following awkward logic is to parse ZERO or more strings,
4525 comma separated. Recall a string expression includes spaces
4526 before the opening '\"' and spaces after the closing '\"'.
4527 We fake a leading ',' if there is (supposed to be)
4528 a 1st, expression. We keep demanding expressions for each ','. */
4529 if (is_it_end_of_statement ())
4531 c
= 0; /* Skip loop. */
4532 ++input_line_pointer
; /* Compensate for end of loop. */
4536 c
= ','; /* Do loop. */
4538 while (c
== ',' || c
== '<' || c
== '"')
4541 switch (*input_line_pointer
)
4544 ++input_line_pointer
; /*->1st char of string. */
4545 start
= input_line_pointer
;
4546 while (is_a_char (c
= next_char_of_string ()))
4548 FRAG_APPEND_1_CHAR (c
);
4552 FRAG_APPEND_1_CHAR (0);
4554 know (input_line_pointer
[-1] == '\"');
4558 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4559 will emit .string with a filename in the .debug section
4560 after a sequence of constants. See the comment in
4561 emit_expr for the sequence. emit_expr will set
4562 dwarf_file_string to non-zero if this string might be a
4563 source file name. */
4564 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4565 dwarf_file_string
= 0;
4566 else if (dwarf_file_string
)
4568 c
= input_line_pointer
[-1];
4569 input_line_pointer
[-1] = '\0';
4570 listing_source_file (start
);
4571 input_line_pointer
[-1] = c
;
4578 input_line_pointer
++;
4579 c
= get_single_number ();
4580 FRAG_APPEND_1_CHAR (c
);
4581 if (*input_line_pointer
!= '>')
4583 as_bad (_("expected <nn>"));
4585 input_line_pointer
++;
4588 input_line_pointer
++;
4592 c
= *input_line_pointer
;
4595 demand_empty_rest_of_line ();
4598 /* FIXME-SOMEDAY: I had trouble here on characters with the
4599 high bits set. We'll probably also have trouble with
4600 multibyte chars, wide chars, etc. Also be careful about
4601 returning values bigger than 1 byte. xoxorich. */
4604 next_char_of_string ()
4606 register unsigned int c
;
4608 c
= *input_line_pointer
++ & CHAR_MASK
;
4616 as_warn (_("unterminated string; newline inserted"));
4617 bump_line_counters ();
4620 #ifndef NO_STRING_ESCAPES
4622 switch (c
= *input_line_pointer
++)
4650 break; /* As itself. */
4666 for (i
= 0, number
= 0;
4667 ISDIGIT (c
) && i
< 3;
4668 c
= *input_line_pointer
++, i
++)
4670 number
= number
* 8 + c
- '0';
4675 --input_line_pointer
;
4684 c
= *input_line_pointer
++;
4685 while (ISXDIGIT (c
))
4688 number
= number
* 16 + c
- '0';
4689 else if (ISUPPER (c
))
4690 number
= number
* 16 + c
- 'A' + 10;
4692 number
= number
* 16 + c
- 'a' + 10;
4693 c
= *input_line_pointer
++;
4696 --input_line_pointer
;
4701 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4702 as_warn (_("unterminated string; newline inserted"));
4704 bump_line_counters ();
4709 #ifdef ONLY_STANDARD_ESCAPES
4710 as_bad (_("bad escaped character in string"));
4712 #endif /* ONLY_STANDARD_ESCAPES */
4717 #endif /* ! defined (NO_STRING_ESCAPES) */
4726 get_segmented_expression (expP
)
4727 register expressionS
*expP
;
4729 register segT retval
;
4731 retval
= expression (expP
);
4732 if (expP
->X_op
== O_illegal
4733 || expP
->X_op
== O_absent
4734 || expP
->X_op
== O_big
)
4736 as_bad (_("expected address expression"));
4737 expP
->X_op
= O_constant
;
4738 expP
->X_add_number
= 0;
4739 retval
= absolute_section
;
4745 get_known_segmented_expression (expP
)
4746 register expressionS
*expP
;
4748 register segT retval
;
4750 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4752 /* There is no easy way to extract the undefined symbol from the
4754 if (expP
->X_add_symbol
!= NULL
4755 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4756 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4757 S_GET_NAME (expP
->X_add_symbol
));
4759 as_warn (_("some symbol undefined; zero assumed"));
4760 retval
= absolute_section
;
4761 expP
->X_op
= O_constant
;
4762 expP
->X_add_number
= 0;
4764 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4769 get_absolute_expression ()
4774 if (exp
.X_op
!= O_constant
)
4776 if (exp
.X_op
!= O_absent
)
4777 as_bad (_("bad or irreducible absolute expression"));
4778 exp
.X_add_number
= 0;
4780 return exp
.X_add_number
;
4783 char /* Return terminator. */
4784 get_absolute_expression_and_terminator (val_pointer
)
4785 long *val_pointer
; /* Return value of expression. */
4787 /* FIXME: val_pointer should probably be offsetT *. */
4788 *val_pointer
= (long) get_absolute_expression ();
4789 return (*input_line_pointer
++);
4792 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4793 Give a warning if that happens. */
4796 demand_copy_C_string (len_pointer
)
4801 if ((s
= demand_copy_string (len_pointer
)) != 0)
4805 for (len
= *len_pointer
; len
> 0; len
--)
4812 as_bad (_("this string may not contain \'\\0\'"));
4820 /* Demand string, but return a safe (=private) copy of the string.
4821 Return NULL if we can't read a string here. */
4824 demand_copy_string (lenP
)
4827 register unsigned int c
;
4833 if (*input_line_pointer
== '\"')
4835 input_line_pointer
++; /* Skip opening quote. */
4837 while (is_a_char (c
= next_char_of_string ()))
4839 obstack_1grow (¬es
, c
);
4842 /* JF this next line is so demand_copy_C_string will return a
4843 null terminated string. */
4844 obstack_1grow (¬es
, '\0');
4845 retval
= obstack_finish (¬es
);
4849 as_warn (_("missing string"));
4851 ignore_rest_of_line ();
4857 /* In: Input_line_pointer->next character.
4859 Do: Skip input_line_pointer over all whitespace.
4861 Out: 1 if input_line_pointer->end-of-line. */
4864 is_it_end_of_statement ()
4867 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4871 equals (sym_name
, reassign
)
4875 register symbolS
*symbolP
; /* Symbol we are working with. */
4879 input_line_pointer
++;
4880 if (*input_line_pointer
== '=')
4881 input_line_pointer
++;
4883 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4884 input_line_pointer
++;
4887 stop
= mri_comment_field (&stopc
);
4889 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4891 /* Turn '. = mumble' into a .org mumble. */
4892 register segT segment
;
4895 segment
= get_known_segmented_expression (&exp
);
4897 do_org (segment
, &exp
, 0);
4904 symbolP
= symbol_find (sym_name
);
4905 local
= symbolP
== NULL
;
4907 #endif /* OBJ_COFF */
4908 symbolP
= symbol_find_or_make (sym_name
);
4909 /* Permit register names to be redefined. */
4911 && S_IS_DEFINED (symbolP
)
4912 && S_GET_SEGMENT (symbolP
) != reg_section
)
4913 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
4916 /* "set" symbols are local unless otherwise specified. */
4918 SF_SET_LOCAL (symbolP
);
4919 #endif /* OBJ_COFF */
4921 pseudo_set (symbolP
);
4926 /* Check garbage after the expression. */
4927 ignore_rest_of_line ();
4928 mri_comment_end (stop
, stopc
);
4932 /* .incbin -- include a file verbatim at the current location. */
4936 int x ATTRIBUTE_UNUSED
;
4947 #ifdef md_flush_pending_output
4948 md_flush_pending_output ();
4952 filename
= demand_copy_string (& len
);
4953 if (filename
== NULL
)
4958 /* Look for optional skip and count. */
4959 if (* input_line_pointer
== ',')
4961 ++ input_line_pointer
;
4962 skip
= get_absolute_expression ();
4966 if (* input_line_pointer
== ',')
4968 ++ input_line_pointer
;
4970 count
= get_absolute_expression ();
4972 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
4978 demand_empty_rest_of_line ();
4980 /* Try opening absolute path first, then try include dirs. */
4981 binfile
= fopen (filename
, FOPEN_RB
);
4982 if (binfile
== NULL
)
4986 path
= xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
4988 for (i
= 0; i
< include_dir_count
; i
++)
4990 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
4992 binfile
= fopen (path
, FOPEN_RB
);
4993 if (binfile
!= NULL
)
4997 if (binfile
== NULL
)
4998 as_bad (_("file not found: %s"), filename
);
5001 path
= xstrdup (filename
);
5007 register_dependency (path
);
5009 /* Compute the length of the file. */
5010 if (fseek (binfile
, 0, SEEK_END
) != 0)
5012 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
5015 file_len
= ftell (binfile
);
5017 /* If a count was not specified use the size of the file. */
5021 if (skip
+ count
> file_len
)
5023 as_bad (_("skip (%ld) + count (%ld) larger than file size (%ld)"),
5024 skip
, count
, file_len
);
5028 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
5030 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
5034 /* Allocate frag space and store file contents in it. */
5035 binfrag
= frag_more (count
);
5037 bytes
= fread (binfrag
, 1, count
, binfile
);
5039 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5040 path
, bytes
, count
);
5043 if (binfile
!= NULL
)
5049 /* .include -- include a file at this point. */
5053 int arg ATTRIBUTE_UNUSED
;
5062 filename
= demand_copy_string (&i
);
5063 if (filename
== NULL
)
5065 /* demand_copy_string has already printed an error and
5066 called ignore_rest_of_line. */
5074 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5075 && *input_line_pointer
!= ' '
5076 && *input_line_pointer
!= '\t')
5078 obstack_1grow (¬es
, *input_line_pointer
);
5079 ++input_line_pointer
;
5083 obstack_1grow (¬es
, '\0');
5084 filename
= obstack_finish (¬es
);
5085 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5086 ++input_line_pointer
;
5089 demand_empty_rest_of_line ();
5090 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
5092 for (i
= 0; i
< include_dir_count
; i
++)
5094 strcpy (path
, include_dirs
[i
]);
5096 strcat (path
, filename
);
5097 if (0 != (try = fopen (path
, FOPEN_RT
)))
5107 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5108 register_dependency (path
);
5109 input_scrub_insert_file (path
);
5113 add_include_dir (path
)
5118 if (include_dir_count
== 0)
5120 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5121 include_dirs
[0] = "."; /* Current dir. */
5122 include_dir_count
= 2;
5126 include_dir_count
++;
5128 (char **) realloc (include_dirs
,
5129 include_dir_count
* sizeof (*include_dirs
));
5132 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5135 if (i
> include_dir_maxlen
)
5136 include_dir_maxlen
= i
;
5139 /* Output debugging information to denote the source file. */
5142 generate_file_debug ()
5144 if (debug_type
== DEBUG_STABS
)
5145 stabs_generate_asm_file ();
5148 /* Output line number debugging information for the current source line. */
5151 generate_lineno_debug ()
5155 case DEBUG_UNSPECIFIED
:
5160 stabs_generate_asm_lineno ();
5163 ecoff_generate_asm_lineno ();
5166 /* ??? We could here indicate to dwarf2dbg.c that something
5167 has changed. However, since there is additional backend
5168 support that is required (calling dwarf2_emit_insn), we
5169 let dwarf2dbg.c call as_where on its own. */
5174 /* Output debugging information to mark a function entry point or end point.
5175 END_P is zero for .func, and non-zero for .endfunc. */
5181 do_s_func (end_p
, NULL
);
5184 /* Subroutine of s_func so targets can choose a different default prefix.
5185 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5188 do_s_func (end_p
, default_prefix
)
5190 const char *default_prefix
;
5192 /* Record the current function so that we can issue an error message for
5193 misplaced .func,.endfunc, and also so that .endfunc needs no
5195 static char *current_name
;
5196 static char *current_label
;
5200 if (current_name
== NULL
)
5202 as_bad (_("missing .func"));
5203 ignore_rest_of_line ();
5207 if (debug_type
== DEBUG_STABS
)
5208 stabs_generate_asm_endfunc (current_name
, current_label
);
5210 current_name
= current_label
= NULL
;
5215 char delim1
, delim2
;
5217 if (current_name
!= NULL
)
5219 as_bad (_(".endfunc missing for previous .func"));
5220 ignore_rest_of_line ();
5224 name
= input_line_pointer
;
5225 delim1
= get_symbol_end ();
5226 name
= xstrdup (name
);
5227 *input_line_pointer
= delim1
;
5229 if (*input_line_pointer
!= ',')
5232 asprintf (&label
, "%s%s", default_prefix
, name
);
5235 char leading_char
= 0;
5236 #ifdef BFD_ASSEMBLER
5237 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5239 /* Missing entry point, use function's name with the leading
5242 asprintf (&label
, "%c%s", leading_char
, name
);
5249 ++input_line_pointer
;
5251 label
= input_line_pointer
;
5252 delim2
= get_symbol_end ();
5253 label
= xstrdup (label
);
5254 *input_line_pointer
= delim2
;
5257 if (debug_type
== DEBUG_STABS
)
5258 stabs_generate_asm_func (name
, label
);
5260 current_name
= name
;
5261 current_label
= label
;
5264 demand_empty_rest_of_line ();
5269 int arg ATTRIBUTE_UNUSED
;
5271 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5273 ++input_line_pointer
;
5275 ++input_line_pointer
;
5279 read_print_statistics (file
)
5282 hash_print_statistics (file
, "pseudo-op table", po_hash
);
5285 /* Inserts the given line into the input stream.
5287 This call avoids macro/conditionals nesting checking, since the contents of
5288 the line are assumed to replace the contents of a line already scanned.
5290 An appropriate use of this function would be substition of input lines when
5291 called by md_start_line_hook(). The given line is assumed to already be
5292 properly scrubbed. */
5295 input_scrub_insert_line (line
)
5300 sb_add_string (&newline
, line
);
5301 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
5303 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
5306 /* Insert a file into the input stream; the path must resolve to an actual
5307 file; no include path searching or dependency registering is performed. */
5310 input_scrub_insert_file (path
)
5313 input_scrub_include_file (path
, input_line_pointer
);
5314 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);