1 /* read.c - read a source file -
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001, 2002, 2003 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 /* Variables for handling include file directory table. */
173 /* Table of pointers to directories to search for .include's. */
176 /* How many are in the table. */
177 int include_dir_count
;
179 /* Length of longest in table. */
180 int include_dir_maxlen
= 1;
182 #ifndef WORKING_DOT_WORD
183 struct broken_word
*broken_words
;
184 int new_broken_words
;
187 /* The current offset into the absolute section. We don't try to
188 build frags in the absolute section, since no data can be stored
189 there. We just keep track of the current offset. */
190 addressT abs_section_offset
;
192 /* If this line had an MRI style label, it is stored in this variable.
193 This is used by some of the MRI pseudo-ops. */
196 /* This global variable is used to support MRI common sections. We
197 translate such sections into a common symbol. This variable is
198 non-NULL when we are in an MRI common section. */
199 symbolS
*mri_common_symbol
;
201 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
202 need to align to an even byte boundary unless the next pseudo-op is
203 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
205 static int mri_pending_align
;
209 /* This variable is set to be non-zero if the next string we see might
210 be the name of the source file in DWARF debugging information. See
211 the comment in emit_expr for the format we look for. */
212 static int dwarf_file_string
;
216 static void cons_worker
PARAMS ((int, int));
217 static int scrub_from_string
PARAMS ((char *, int));
218 static void do_align
PARAMS ((int, char *, int, int));
219 static void s_align
PARAMS ((int, int));
220 static void s_lcomm_internal
PARAMS ((int, int));
221 static int hex_float
PARAMS ((int, char *));
222 static inline int sizeof_sleb128
PARAMS ((offsetT
));
223 static inline int sizeof_uleb128
PARAMS ((valueT
));
224 static inline int output_sleb128
PARAMS ((char *, offsetT
));
225 static inline int output_uleb128
PARAMS ((char *, valueT
));
226 static inline int output_big_sleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
227 static inline int output_big_uleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
228 static int output_big_leb128
PARAMS ((char *, LITTLENUM_TYPE
*, int, int));
229 static void do_org
PARAMS ((segT
, expressionS
*, int));
230 char *demand_copy_string
PARAMS ((int *lenP
));
231 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
232 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
233 static void pobegin
PARAMS ((void));
234 static int get_line_sb
PARAMS ((sb
*));
235 static void generate_file_debug
PARAMS ((void));
243 obj_read_begin_hook ();
245 /* Something close -- but not too close -- to a multiple of 1024.
246 The debugging malloc I'm using has 24 bytes of overhead. */
247 obstack_begin (¬es
, chunksize
);
248 obstack_begin (&cond_obstack
, chunksize
);
250 /* Use machine dependent syntax. */
251 for (p
= line_separator_chars
; *p
; p
++)
252 is_end_of_line
[(unsigned char) *p
] = 1;
253 /* Use more. FIXME-SOMEDAY. */
259 /* Set up pseudo-op tables. */
261 static struct hash_control
*po_hash
;
263 static const pseudo_typeS potable
[] = {
264 {"abort", s_abort
, 0},
265 {"align", s_align_ptwo
, 0},
266 {"ascii", stringer
, 0},
267 {"asciz", stringer
, 1},
268 {"balign", s_align_bytes
, 0},
269 {"balignw", s_align_bytes
, -2},
270 {"balignl", s_align_bytes
, -4},
274 {"common", s_mri_common
, 0},
275 {"common.s", s_mri_common
, 1},
279 {"dc.d", float_cons
, 'd'},
281 {"dc.s", float_cons
, 'f'},
283 {"dc.x", float_cons
, 'x'},
285 {"dcb.b", s_space
, 1},
286 {"dcb.d", s_float_space
, 'd'},
287 {"dcb.l", s_space
, 4},
288 {"dcb.s", s_float_space
, 'f'},
289 {"dcb.w", s_space
, 2},
290 {"dcb.x", s_float_space
, 'x'},
292 {"ds.b", s_space
, 1},
293 {"ds.d", s_space
, 8},
294 {"ds.l", s_space
, 4},
295 {"ds.p", s_space
, 12},
296 {"ds.s", s_space
, 4},
297 {"ds.w", s_space
, 2},
298 {"ds.x", s_space
, 12},
299 {"debug", s_ignore
, 0},
304 {"double", float_cons
, 'd'},
306 {"eject", listing_eject
, 0}, /* Formfeed listing. */
308 {"elsec", s_else
, 0},
309 {"elseif", s_elseif
, (int) O_ne
},
311 {"endc", s_endif
, 0},
312 {"endfunc", s_func
, 1},
313 {"endif", s_endif
, 0},
314 {"endr", s_bad_endr
, 0},
319 {"exitm", s_mexit
, 0},
321 {"extern", s_ignore
, 0}, /* We treat all undef as ext. */
322 {"appfile", s_app_file
, 1},
323 {"appline", s_app_line
, 0},
325 {"file", s_app_file
, 0},
327 {"float", float_cons
, 'f'},
328 {"format", s_ignore
, 0},
330 {"global", s_globl
, 0},
331 {"globl", s_globl
, 0},
333 {"if", s_if
, (int) O_ne
},
335 {"ifdef", s_ifdef
, 0},
336 {"ifeq", s_if
, (int) O_eq
},
337 {"ifeqs", s_ifeqs
, 0},
338 {"ifge", s_if
, (int) O_ge
},
339 {"ifgt", s_if
, (int) O_gt
},
340 {"ifle", s_if
, (int) O_le
},
341 {"iflt", s_if
, (int) O_lt
},
343 {"ifndef", s_ifdef
, 1},
344 {"ifne", s_if
, (int) O_ne
},
345 {"ifnes", s_ifeqs
, 1},
346 {"ifnotdef", s_ifdef
, 1},
347 {"incbin", s_incbin
, 0},
348 {"include", s_include
, 0},
354 {"lcomm", s_lcomm
, 0},
355 {"lflags", listing_flags
, 0}, /* Listing flags. */
356 {"linkonce", s_linkonce
, 0},
357 {"list", listing_list
, 1}, /* Turn listing on. */
358 {"llen", listing_psize
, 1},
361 {"macro", s_macro
, 0},
362 {"mexit", s_mexit
, 0},
364 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
365 {"name", s_ignore
, 0},
366 {"noformat", s_ignore
, 0},
367 {"nolist", listing_list
, 0}, /* Turn listing off. */
368 {"nopage", listing_nopage
, 0},
370 {"offset", s_struct
, 0},
372 {"p2align", s_align_ptwo
, 0},
373 {"p2alignw", s_align_ptwo
, -2},
374 {"p2alignl", s_align_ptwo
, -4},
375 {"page", listing_eject
, 0},
376 {"plen", listing_psize
, 0},
377 {"print", s_print
, 0},
378 {"psize", listing_psize
, 0}, /* Set paper size. */
379 {"purgem", s_purgem
, 0},
384 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
389 {"single", float_cons
, 'f'},
391 {"space", s_space
, 0},
392 {"skip", s_space
, 0},
393 {"sleb128", s_leb128
, 1},
394 {"spc", s_ignore
, 0},
395 {"stabd", s_stab
, 'd'},
396 {"stabn", s_stab
, 'n'},
397 {"stabs", s_stab
, 's'},
398 {"string", stringer
, 1},
399 {"struct", s_struct
, 0},
403 /* This is for gcc to use. It's only just been added (2/94), so gcc
404 won't be able to use it for a while -- probably a year or more.
405 But once this has been released, check with gcc maintainers
406 before deleting it or even changing the spelling. */
407 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
408 /* If we're folding case -- done for some targets, not necessarily
409 all -- the above string in an input file will be converted to
410 this one. Match it either way... */
411 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
413 {"title", listing_title
, 0}, /* Listing title. */
414 {"ttl", listing_title
, 0},
416 {"uleb128", s_leb128
, 0},
420 {"xdef", s_globl
, 0},
421 {"xref", s_ignore
, 0},
422 {"xstabs", s_xstab
, 's'},
424 {"zero", s_space
, 0},
425 {NULL
, NULL
, 0} /* End sentinel. */
428 static int pop_override_ok
= 0;
429 static const char *pop_table_name
;
433 const pseudo_typeS
*table
;
436 const pseudo_typeS
*pop
;
437 for (pop
= table
; pop
->poc_name
; pop
++)
439 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
440 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
441 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
446 #ifndef md_pop_insert
447 #define md_pop_insert() pop_insert(md_pseudo_table)
450 #ifndef obj_pop_insert
451 #define obj_pop_insert() pop_insert(obj_pseudo_table)
457 po_hash
= hash_new ();
459 /* Do the target-specific pseudo ops. */
460 pop_table_name
= "md";
463 /* Now object specific. Skip any that were in the target table. */
464 pop_table_name
= "obj";
468 /* Now portable ones. Skip any that we've seen already. */
469 pop_table_name
= "standard";
470 pop_insert (potable
);
473 #define HANDLE_CONDITIONAL_ASSEMBLY() \
474 if (ignore_input ()) \
476 while (!is_end_of_line[(unsigned char) *input_line_pointer++]) \
477 if (input_line_pointer == buffer_limit) \
482 /* This function is used when scrubbing the characters between #APP
485 static char *scrub_string
;
486 static char *scrub_string_end
;
489 scrub_from_string (buf
, buflen
)
495 copy
= scrub_string_end
- scrub_string
;
498 memcpy (buf
, scrub_string
, copy
);
499 scrub_string
+= copy
;
503 /* We read the file, putting things into a web that represents what we
504 have been reading. */
506 read_a_source_file (name
)
510 register char *s
; /* String of symbol, '\0' appended. */
518 buffer
= input_scrub_new_file (name
);
521 listing_newline (NULL
);
522 register_dependency (name
);
524 /* Generate debugging information before we've read anything in to denote
525 this file as the "main" source file and not a subordinate one
526 (e.g. N_SO vs N_SOL in stabs). */
527 generate_file_debug ();
529 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
530 { /* We have another line to parse. */
531 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
533 while (input_line_pointer
< buffer_limit
)
535 /* We have more of this buffer to parse. */
537 /* We now have input_line_pointer->1st char of next line.
538 If input_line_pointer [-1] == '\n' then we just
539 scanned another line: so bump line counters. */
540 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
542 #ifdef md_start_line_hook
543 md_start_line_hook ();
545 if (input_line_pointer
[-1] == '\n')
546 bump_line_counters ();
550 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
552 /* Text at the start of a line must be a label, we
553 run down and stick a colon in. */
554 if (is_name_beginner (*input_line_pointer
))
556 char *line_start
= input_line_pointer
;
561 HANDLE_CONDITIONAL_ASSEMBLY ();
563 c
= get_symbol_end ();
565 /* In MRI mode, the EQU and MACRO pseudoops must
566 be handled specially. */
570 char *rest
= input_line_pointer
+ 1;
574 if (*rest
== ' ' || *rest
== '\t')
576 if ((strncasecmp (rest
, "EQU", 3) == 0
577 || strncasecmp (rest
, "SET", 3) == 0)
578 && (rest
[3] == ' ' || rest
[3] == '\t'))
580 input_line_pointer
= rest
+ 3;
582 strncasecmp (rest
, "SET", 3) == 0);
585 if (strncasecmp (rest
, "MACRO", 5) == 0
588 || is_end_of_line
[(unsigned char) rest
[5]]))
592 /* In MRI mode, we need to handle the MACRO
593 pseudo-op specially: we don't want to put the
594 symbol in the symbol table. */
596 #ifdef TC_START_LABEL_WITHOUT_COLON
597 && TC_START_LABEL_WITHOUT_COLON(c
,
601 line_label
= colon (line_start
);
603 line_label
= symbol_create (line_start
,
608 *input_line_pointer
= c
;
610 input_line_pointer
++;
615 /* We are at the begining of a line, or similar place.
616 We expect a well-formed assembler statement.
617 A "symbol-name:" is a statement.
619 Depending on what compiler is used, the order of these tests
620 may vary to catch most common case 1st.
621 Each test is independent of all other tests at the (top) level.
622 PLEASE make a compiler that doesn't use this assembler.
623 It is crufty to waste a compiler's time encoding things for this
624 assembler, which then wastes more time decoding it.
625 (And communicating via (linear) files is silly!
626 If you must pass stuff, please pass a tree!) */
627 if ((c
= *input_line_pointer
++) == '\t'
631 c
= *input_line_pointer
++;
633 know (c
!= ' '); /* No further leading whitespace. */
636 /* If listing is on, and we are expanding a macro, then give
637 the listing code the contents of the expanded line. */
640 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
645 /* Find the end of the current expanded macro line. */
646 for (s
= input_line_pointer
- 1; *s
; ++s
)
647 if (is_end_of_line
[(unsigned char) *s
])
650 /* Copy it for safe keeping. Also give an indication of
651 how much macro nesting is involved at this point. */
652 len
= s
- (input_line_pointer
- 1);
653 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
654 memset (copy
, '>', macro_nest
);
655 copy
[macro_nest
] = ' ';
656 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
- 1, len
);
657 copy
[macro_nest
+ 1 + len
] = '\0';
659 /* Install the line with the listing facility. */
660 listing_newline (copy
);
663 listing_newline (NULL
);
666 /* C is the 1st significant character.
667 Input_line_pointer points after that character. */
668 if (is_name_beginner (c
))
670 /* Want user-defined label or pseudo/opcode. */
671 HANDLE_CONDITIONAL_ASSEMBLY ();
673 s
= --input_line_pointer
;
674 c
= get_symbol_end (); /* name's delimiter. */
676 /* C is character after symbol.
677 That character's place in the input line is now '\0'.
678 S points to the beginning of the symbol.
679 [In case of pseudo-op, s->'.'.]
680 Input_line_pointer->'\0' where c was. */
681 if (TC_START_LABEL (c
, input_line_pointer
))
685 char *rest
= input_line_pointer
+ 1;
687 /* In MRI mode, \tsym: set 0 is permitted. */
691 if (*rest
== ' ' || *rest
== '\t')
694 if ((strncasecmp (rest
, "EQU", 3) == 0
695 || strncasecmp (rest
, "SET", 3) == 0)
696 && (rest
[3] == ' ' || rest
[3] == '\t'))
698 input_line_pointer
= rest
+ 3;
704 line_label
= colon (s
); /* User-defined label. */
705 /* Put ':' back for error messages' sake. */
706 *input_line_pointer
++ = ':';
707 #ifdef tc_check_label
708 tc_check_label (line_label
);
710 /* Input_line_pointer->after ':'. */
714 || ((c
== ' ' || c
== '\t')
715 && input_line_pointer
[1] == '='
716 #ifdef TC_EQUAL_IN_INSN
717 && !TC_EQUAL_IN_INSN (c
, input_line_pointer
)
722 demand_empty_rest_of_line ();
726 /* Expect pseudo-op or machine instruction. */
729 #ifdef IGNORE_OPCODE_CASE
733 strncpy (original_case_string
, s2
, sizeof (original_case_string
));
734 original_case_string
[sizeof (original_case_string
) - 1] = 0;
743 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
745 /* The MRI assembler and the m88k use pseudo-ops
747 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
748 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
753 || (!flag_m68k_mri
&& *s
== '.'))
757 WARNING: c has next char, which may be end-of-line.
758 We lookup the pseudo-op table with s+1 because we
759 already know that the pseudo-op begins with a '.'. */
762 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
764 /* In MRI mode, we may need to insert an
765 automatic alignment directive. What a hack
767 if (mri_pending_align
769 || !((pop
->poc_handler
== cons
770 && pop
->poc_val
== 1)
771 || (pop
->poc_handler
== s_space
772 && pop
->poc_val
== 1)
773 #ifdef tc_conditional_pseudoop
774 || tc_conditional_pseudoop (pop
)
776 || pop
->poc_handler
== s_if
777 || pop
->poc_handler
== s_ifdef
778 || pop
->poc_handler
== s_ifc
779 || pop
->poc_handler
== s_ifeqs
780 || pop
->poc_handler
== s_else
781 || pop
->poc_handler
== s_endif
782 || pop
->poc_handler
== s_globl
783 || pop
->poc_handler
== s_ignore
)))
785 do_align (1, (char *) NULL
, 0, 0);
786 mri_pending_align
= 0;
788 if (line_label
!= NULL
)
790 symbol_set_frag (line_label
, frag_now
);
791 S_SET_VALUE (line_label
, frag_now_fix ());
795 /* Print the error msg now, while we still can. */
798 as_bad (_("unknown pseudo-op: `%s'"), s
);
799 *input_line_pointer
= c
;
804 /* Put it back for error messages etc. */
805 *input_line_pointer
= c
;
806 /* The following skip of whitespace is compulsory.
807 A well shaped space is sometimes all that separates
808 keyword from operands. */
809 if (c
== ' ' || c
== '\t')
810 input_line_pointer
++;
812 /* Input_line is restored.
813 Input_line_pointer->1st non-blank char
814 after pseudo-operation. */
815 (*pop
->poc_handler
) (pop
->poc_val
);
817 /* If that was .end, just get out now. */
818 if (pop
->poc_handler
== s_end
)
824 #ifdef QUOTES_IN_INSN
828 /* WARNING: c has char, which may be end-of-line. */
829 /* Also: input_line_pointer->`\0` where c was. */
830 *input_line_pointer
= c
;
831 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
833 #ifdef TC_EOL_IN_INSN
834 || TC_EOL_IN_INSN (input_line_pointer
)
838 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
840 #ifdef QUOTES_IN_INSN
843 else if (*input_line_pointer
== '"')
845 else if (*input_line_pointer
== '\\')
848 input_line_pointer
++;
851 c
= *input_line_pointer
;
852 *input_line_pointer
= '\0';
854 generate_lineno_debug ();
862 if (check_macro (s
, &out
, &err
, ¯o
))
866 *input_line_pointer
++ = c
;
867 input_scrub_include_sb (&out
,
868 input_line_pointer
, 1);
871 input_scrub_next_buffer (&input_line_pointer
);
873 md_macro_info (macro
);
879 if (mri_pending_align
)
881 do_align (1, (char *) NULL
, 0, 0);
882 mri_pending_align
= 0;
883 if (line_label
!= NULL
)
885 symbol_set_frag (line_label
, frag_now
);
886 S_SET_VALUE (line_label
, frag_now_fix ());
890 md_assemble (s
); /* Assemble 1 instruction. */
892 *input_line_pointer
++ = c
;
894 /* We resume loop AFTER the end-of-line from
901 /* Empty statement? */
902 if (is_end_of_line
[(unsigned char) c
])
905 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
) && ISDIGIT (c
))
907 /* local label ("4:") */
908 char *backup
= input_line_pointer
;
910 HANDLE_CONDITIONAL_ASSEMBLY ();
914 /* Read the whole number. */
915 while (ISDIGIT (*input_line_pointer
))
917 temp
= (temp
* 10) + *input_line_pointer
- '0';
918 ++input_line_pointer
;
921 if (LOCAL_LABELS_DOLLAR
922 && *input_line_pointer
== '$'
923 && *(input_line_pointer
+ 1) == ':')
925 input_line_pointer
+= 2;
927 if (dollar_label_defined (temp
))
929 as_fatal (_("label \"%d$\" redefined"), temp
);
932 define_dollar_label (temp
);
933 colon (dollar_label_name (temp
, 0));
938 && *input_line_pointer
++ == ':')
940 fb_label_instance_inc (temp
);
941 colon (fb_label_name (temp
, 0));
945 input_line_pointer
= backup
;
946 } /* local label ("4:") */
948 if (c
&& strchr (line_comment_chars
, c
))
949 { /* Its a comment. Better say APP or NO_APP. */
954 unsigned int new_length
;
957 bump_line_counters ();
958 s
= input_line_pointer
;
959 if (strncmp (s
, "APP\n", 4))
960 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
;
1037 /* We've "scrubbed" input to the preferred format. In the
1038 process we may have consumed the whole of the remaining
1039 file (and included files). We handle this formatted
1040 input similar to that of macro expansion, letting
1041 actual macro expansion (possibly nested) and other
1042 input expansion work. Beware that in messages, line
1043 numbers and possibly file names will be incorrect. */
1044 sb_add_string (&sbuf
, new_buf
);
1045 input_scrub_include_sb (&sbuf
, input_line_pointer
, 0);
1047 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1052 HANDLE_CONDITIONAL_ASSEMBLY ();
1054 #ifdef tc_unrecognized_line
1055 if (tc_unrecognized_line (c
))
1058 input_line_pointer
--;
1059 /* Report unknown char as ignored. */
1060 ignore_rest_of_line ();
1063 #ifdef md_after_pass_hook
1064 md_after_pass_hook ();
1073 /* Close the input file. */
1074 input_scrub_close ();
1075 #ifdef WARN_COMMENTS
1077 if (warn_comment
&& found_comment
)
1078 as_warn_where (found_comment_file
, found_comment
,
1079 "first comment found here");
1084 /* For most MRI pseudo-ops, the line actually ends at the first
1085 nonquoted space. This function looks for that point, stuffs a null
1086 in, and sets *STOPCP to the character that used to be there, and
1087 returns the location.
1089 Until I hear otherwise, I am going to assume that this is only true
1090 for the m68k MRI assembler. */
1093 mri_comment_field (stopcp
)
1100 know (flag_m68k_mri
);
1102 for (s
= input_line_pointer
;
1103 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1111 for (s
= input_line_pointer
;
1112 !is_end_of_line
[(unsigned char) *s
];
1122 /* Skip to the end of an MRI comment field. */
1125 mri_comment_end (stop
, stopc
)
1131 input_line_pointer
= stop
;
1133 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1134 ++input_line_pointer
;
1139 int ignore ATTRIBUTE_UNUSED
;
1141 as_fatal (_(".abort detected. Abandoning ship."));
1144 /* Guts of .align directive. N is the power of two to which to align.
1145 FILL may be NULL, or it may point to the bytes of the fill pattern.
1146 LEN is the length of whatever FILL points to, if anything. MAX is
1147 the maximum number of characters to skip when doing the alignment,
1148 or 0 if there is no maximum. */
1151 do_align (n
, fill
, len
, max
)
1157 if (now_seg
== absolute_section
)
1161 if (*fill
++ != '\0')
1163 as_warn (_("ignoring fill value in absolute section"));
1171 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1174 /* Only make a frag if we HAVE to... */
1175 if (n
!= 0 && !need_pass_2
)
1179 if (subseg_text_p (now_seg
))
1180 frag_align_code (n
, max
);
1182 frag_align (n
, 0, max
);
1185 frag_align (n
, *fill
, max
);
1187 frag_align_pattern (n
, fill
, len
, max
);
1191 just_record_alignment
: ATTRIBUTE_UNUSED_LABEL
1194 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1197 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1198 (in bytes). A negative ARG is the negative of the length of the
1199 fill pattern. BYTES_P is non-zero if the alignment value should be
1200 interpreted as the byte boundary, rather than the power of 2. */
1203 s_align (arg
, bytes_p
)
1207 register unsigned int align
;
1215 stop
= mri_comment_field (&stopc
);
1217 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1222 align
= arg
; /* Default value from pseudo-op table. */
1226 align
= get_absolute_expression ();
1232 /* Convert to a power of 2. */
1237 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1240 as_bad (_("alignment not a power of 2"));
1249 as_warn (_("alignment too large: %u assumed"), align
);
1252 if (*input_line_pointer
!= ',')
1259 ++input_line_pointer
;
1260 if (*input_line_pointer
== ',')
1264 fill
= get_absolute_expression ();
1269 if (*input_line_pointer
!= ',')
1273 ++input_line_pointer
;
1274 max
= get_absolute_expression ();
1281 as_warn (_("expected fill pattern missing"));
1282 do_align (align
, (char *) NULL
, 0, max
);
1297 do_align (align
, &fill_char
, fill_len
, max
);
1303 if ((size_t) fill_len
> sizeof ab
)
1305 md_number_to_chars (ab
, fill
, fill_len
);
1306 do_align (align
, ab
, fill_len
, max
);
1310 demand_empty_rest_of_line ();
1313 mri_comment_end (stop
, stopc
);
1316 /* Handle the .align pseudo-op on machines where ".align 4" means
1317 align to a 4 byte boundary. */
1326 /* Handle the .align pseudo-op on machines where ".align 4" means align
1327 to a 2**4 boundary. */
1338 int ignore ATTRIBUTE_UNUSED
;
1340 register char *name
;
1344 register symbolS
*symbolP
;
1349 stop
= mri_comment_field (&stopc
);
1351 name
= input_line_pointer
;
1352 c
= get_symbol_end ();
1353 /* Just after name is now '\0'. */
1354 p
= input_line_pointer
;
1359 as_bad (_("expected symbol name"));
1360 discard_rest_of_line ();
1366 if (*input_line_pointer
!= ',')
1369 as_bad (_("expected comma after \"%s\""), name
);
1371 ignore_rest_of_line ();
1373 mri_comment_end (stop
, stopc
);
1377 input_line_pointer
++; /* skip ',' */
1379 if ((temp
= get_absolute_expression ()) < 0)
1381 as_warn (_(".COMMon length (%ld) < 0 ignored"), (long) temp
);
1382 ignore_rest_of_line ();
1384 mri_comment_end (stop
, stopc
);
1389 symbolP
= symbol_find_or_make (name
);
1392 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1394 as_bad (_("symbol `%s' is already defined"),
1395 S_GET_NAME (symbolP
));
1396 ignore_rest_of_line ();
1398 mri_comment_end (stop
, stopc
);
1402 if (S_GET_VALUE (symbolP
))
1404 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1405 as_bad (_("length of .comm \"%s\" is already %ld; not changing to %ld"),
1406 S_GET_NAME (symbolP
),
1407 (long) S_GET_VALUE (symbolP
),
1412 S_SET_VALUE (symbolP
, (valueT
) temp
);
1413 S_SET_EXTERNAL (symbolP
);
1417 extern int flag_one
;
1418 if (!temp
|| !flag_one
)
1419 S_GET_OTHER(symbolP
) = const_flag
;
1421 #endif /* not OBJ_VMS */
1422 know (symbolP
->sy_frag
== &zero_address_frag
);
1424 demand_empty_rest_of_line ();
1427 mri_comment_end (stop
, stopc
);
1430 /* The MRI COMMON pseudo-op. We handle this by creating a common
1431 symbol with the appropriate name. We make s_space do the right
1432 thing by increasing the size. */
1435 s_mri_common (small
)
1436 int small ATTRIBUTE_UNUSED
;
1452 stop
= mri_comment_field (&stopc
);
1456 name
= input_line_pointer
;
1457 if (!ISDIGIT (*name
))
1458 c
= get_symbol_end ();
1463 ++input_line_pointer
;
1465 while (ISDIGIT (*input_line_pointer
));
1467 c
= *input_line_pointer
;
1468 *input_line_pointer
= '\0';
1470 if (line_label
!= NULL
)
1472 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1473 + (input_line_pointer
- name
)
1475 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1480 sym
= symbol_find_or_make (name
);
1481 *input_line_pointer
= c
;
1485 if (*input_line_pointer
!= ',')
1489 ++input_line_pointer
;
1490 align
= get_absolute_expression ();
1493 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1495 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1496 ignore_rest_of_line ();
1497 mri_comment_end (stop
, stopc
);
1501 S_SET_EXTERNAL (sym
);
1502 mri_common_symbol
= sym
;
1506 S_SET_ALIGN (sym
, align
);
1509 if (line_label
!= NULL
)
1512 exp
.X_op
= O_symbol
;
1513 exp
.X_add_symbol
= sym
;
1514 exp
.X_add_number
= 0;
1515 symbol_set_value_expression (line_label
, &exp
);
1516 symbol_set_frag (line_label
, &zero_address_frag
);
1517 S_SET_SEGMENT (line_label
, expr_section
);
1520 /* FIXME: We just ignore the small argument, which distinguishes
1521 COMMON and COMMON.S. I don't know what we can do about it. */
1523 /* Ignore the type and hptype. */
1524 if (*input_line_pointer
== ',')
1525 input_line_pointer
+= 2;
1526 if (*input_line_pointer
== ',')
1527 input_line_pointer
+= 2;
1529 demand_empty_rest_of_line ();
1531 mri_comment_end (stop
, stopc
);
1536 int ignore ATTRIBUTE_UNUSED
;
1541 temp
= get_absolute_expression ();
1542 if (flag_readonly_data_in_text
)
1544 section
= text_section
;
1548 section
= data_section
;
1550 subseg_set (section
, (subsegT
) temp
);
1555 demand_empty_rest_of_line ();
1558 /* Handle the .appfile pseudo-op. This is automatically generated by
1559 do_scrub_chars when a preprocessor # line comment is seen with a
1560 file name. This default definition may be overridden by the object
1561 or CPU specific pseudo-ops. This function is also the default
1562 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1566 s_app_file_string (file
)
1571 listing_source_file (file
);
1573 register_dependency (file
);
1575 obj_app_file (file
);
1580 s_app_file (appfile
)
1586 /* Some assemblers tolerate immediately following '"'. */
1587 if ((s
= demand_copy_string (&length
)) != 0)
1589 /* If this is a fake .appfile, a fake newline was inserted into
1590 the buffer. Passing -2 to new_logical_line tells it to
1593 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1595 /* In MRI mode, the preprocessor may have inserted an extraneous
1598 && *input_line_pointer
== '\''
1599 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1600 ++input_line_pointer
;
1602 demand_empty_rest_of_line ();
1604 s_app_file_string (s
);
1608 /* Handle the .appline pseudo-op. This is automatically generated by
1609 do_scrub_chars when a preprocessor # line comment is seen. This
1610 default definition may be overridden by the object or CPU specific
1615 int ignore ATTRIBUTE_UNUSED
;
1619 /* The given number is that of the next line. */
1620 l
= get_absolute_expression () - 1;
1622 /* Some of the back ends can't deal with non-positive line numbers.
1623 Besides, it's silly. */
1624 as_warn (_("line numbers must be positive; line number %d rejected"),
1628 new_logical_line ((char *) NULL
, l
);
1631 listing_source_line (l
);
1634 demand_empty_rest_of_line ();
1637 /* Handle the .end pseudo-op. Actually, the real work is done in
1638 read_a_source_file. */
1642 int ignore ATTRIBUTE_UNUSED
;
1646 /* The MRI assembler permits the start symbol to follow .end,
1647 but we don't support that. */
1649 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1650 && *input_line_pointer
!= '*'
1651 && *input_line_pointer
!= '!')
1652 as_warn (_("start address not supported"));
1656 /* Handle the .err pseudo-op. */
1660 int ignore ATTRIBUTE_UNUSED
;
1662 as_bad (_(".err encountered"));
1663 demand_empty_rest_of_line ();
1666 /* Handle the MRI fail pseudo-op. */
1670 int ignore ATTRIBUTE_UNUSED
;
1677 stop
= mri_comment_field (&stopc
);
1679 temp
= get_absolute_expression ();
1681 as_warn (_(".fail %ld encountered"), (long) temp
);
1683 as_bad (_(".fail %ld encountered"), (long) temp
);
1685 demand_empty_rest_of_line ();
1688 mri_comment_end (stop
, stopc
);
1693 int ignore ATTRIBUTE_UNUSED
;
1695 expressionS rep_exp
;
1697 register long fill
= 0;
1700 #ifdef md_flush_pending_output
1701 md_flush_pending_output ();
1704 get_known_segmented_expression (&rep_exp
);
1705 if (*input_line_pointer
== ',')
1707 input_line_pointer
++;
1708 size
= get_absolute_expression ();
1709 if (*input_line_pointer
== ',')
1711 input_line_pointer
++;
1712 fill
= get_absolute_expression ();
1716 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1717 #define BSD_FILL_SIZE_CROCK_8 (8)
1718 if (size
> BSD_FILL_SIZE_CROCK_8
)
1720 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
1721 size
= BSD_FILL_SIZE_CROCK_8
;
1725 as_warn (_("size negative; .fill ignored"));
1728 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1730 if (rep_exp
.X_add_number
< 0)
1731 as_warn (_("repeat < 0; .fill ignored"));
1735 if (size
&& !need_pass_2
)
1737 if (rep_exp
.X_op
== O_constant
)
1739 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1740 (relax_substateT
) 0, (symbolS
*) 0,
1741 (offsetT
) rep_exp
.X_add_number
,
1746 /* We don't have a constant repeat count, so we can't use
1747 rs_fill. We can get the same results out of rs_space,
1748 but its argument is in bytes, so we must multiply the
1749 repeat count by size. */
1752 rep_sym
= make_expr_symbol (&rep_exp
);
1755 expressionS size_exp
;
1756 size_exp
.X_op
= O_constant
;
1757 size_exp
.X_add_number
= size
;
1759 rep_exp
.X_op
= O_multiply
;
1760 rep_exp
.X_add_symbol
= rep_sym
;
1761 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1762 rep_exp
.X_add_number
= 0;
1763 rep_sym
= make_expr_symbol (&rep_exp
);
1766 p
= frag_var (rs_space
, (int) size
, (int) size
,
1767 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1770 memset (p
, 0, (unsigned int) size
);
1772 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1773 flavoured AS. The following bizarre behaviour is to be
1774 compatible with above. I guess they tried to take up to 8
1775 bytes from a 4-byte expression and they forgot to sign
1777 #define BSD_FILL_SIZE_CROCK_4 (4)
1778 md_number_to_chars (p
, (valueT
) fill
,
1779 (size
> BSD_FILL_SIZE_CROCK_4
1780 ? BSD_FILL_SIZE_CROCK_4
1782 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1783 but emits no error message because it seems a legal thing to do.
1784 It is a degenerate case of .fill but could be emitted by a
1787 demand_empty_rest_of_line ();
1792 int ignore ATTRIBUTE_UNUSED
;
1801 stop
= mri_comment_field (&stopc
);
1805 name
= input_line_pointer
;
1806 c
= get_symbol_end ();
1807 symbolP
= symbol_find_or_make (name
);
1808 S_SET_EXTERNAL (symbolP
);
1810 *input_line_pointer
= c
;
1812 c
= *input_line_pointer
;
1815 input_line_pointer
++;
1817 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1823 demand_empty_rest_of_line ();
1826 mri_comment_end (stop
, stopc
);
1829 /* Handle the MRI IRP and IRPC pseudo-ops. */
1841 as_where (&file
, &line
);
1844 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1845 sb_add_char (&s
, *input_line_pointer
++);
1849 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
);
1851 as_bad_where (file
, line
, "%s", err
);
1855 input_scrub_include_sb (&out
, input_line_pointer
, 1);
1857 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1860 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1861 the section to only be linked once. However, this is not supported
1862 by most object file formats. This takes an optional argument,
1863 which is what to do about duplicates. */
1867 int ignore ATTRIBUTE_UNUSED
;
1869 enum linkonce_type type
;
1873 type
= LINKONCE_DISCARD
;
1875 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1880 s
= input_line_pointer
;
1881 c
= get_symbol_end ();
1882 if (strcasecmp (s
, "discard") == 0)
1883 type
= LINKONCE_DISCARD
;
1884 else if (strcasecmp (s
, "one_only") == 0)
1885 type
= LINKONCE_ONE_ONLY
;
1886 else if (strcasecmp (s
, "same_size") == 0)
1887 type
= LINKONCE_SAME_SIZE
;
1888 else if (strcasecmp (s
, "same_contents") == 0)
1889 type
= LINKONCE_SAME_CONTENTS
;
1891 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1893 *input_line_pointer
= c
;
1896 #ifdef obj_handle_link_once
1897 obj_handle_link_once (type
);
1898 #else /* ! defined (obj_handle_link_once) */
1899 #ifdef BFD_ASSEMBLER
1903 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1904 as_warn (_(".linkonce is not supported for this object file format"));
1906 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1907 flags
|= SEC_LINK_ONCE
;
1912 case LINKONCE_DISCARD
:
1913 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1915 case LINKONCE_ONE_ONLY
:
1916 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1918 case LINKONCE_SAME_SIZE
:
1919 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1921 case LINKONCE_SAME_CONTENTS
:
1922 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1925 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1926 as_bad (_("bfd_set_section_flags: %s"),
1927 bfd_errmsg (bfd_get_error ()));
1929 #else /* ! defined (BFD_ASSEMBLER) */
1930 as_warn (_(".linkonce is not supported for this object file format"));
1931 #endif /* ! defined (BFD_ASSEMBLER) */
1932 #endif /* ! defined (obj_handle_link_once) */
1934 demand_empty_rest_of_line ();
1938 s_lcomm_internal (needs_align
, bytes_p
)
1939 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1940 (alignment); 0 if it was an ".lcomm" (2 args only). */
1942 /* 1 if the alignment value should be interpreted as the byte boundary,
1943 rather than the power of 2. */
1946 register char *name
;
1950 register symbolS
*symbolP
;
1951 segT current_seg
= now_seg
;
1952 subsegT current_subseg
= now_subseg
;
1953 const int max_alignment
= 15;
1955 segT bss_seg
= bss_section
;
1957 name
= input_line_pointer
;
1958 c
= get_symbol_end ();
1959 p
= input_line_pointer
;
1964 as_bad (_("expected symbol name"));
1965 discard_rest_of_line ();
1971 /* Accept an optional comma after the name. The comma used to be
1972 required, but Irix 5 cc does not generate it. */
1973 if (*input_line_pointer
== ',')
1975 ++input_line_pointer
;
1979 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1981 as_bad (_("missing size expression"));
1985 if ((temp
= get_absolute_expression ()) < 0)
1987 as_warn (_("BSS length (%d) < 0 ignored"), temp
);
1988 ignore_rest_of_line ();
1992 #if defined (TC_MIPS) || defined (TC_ALPHA)
1993 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1994 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1996 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1997 if ((unsigned) temp
<= bfd_get_gp_size (stdoutput
))
1999 bss_seg
= subseg_new (".sbss", 1);
2000 seg_info (bss_seg
)->bss
= 1;
2001 #ifdef BFD_ASSEMBLER
2002 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
2003 as_warn (_("error setting flags for \".sbss\": %s"),
2004 bfd_errmsg (bfd_get_error ()));
2012 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
2014 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
2016 record_alignment (bss_seg
, align
);
2024 if (*input_line_pointer
!= ',')
2026 as_bad (_("expected comma after size"));
2027 ignore_rest_of_line ();
2031 input_line_pointer
++;
2034 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2036 as_bad (_("missing alignment"));
2040 align
= get_absolute_expression ();
2044 /* Convert to a power of 2. */
2049 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2052 as_bad (_("alignment not a power of 2"));
2057 if (align
> max_alignment
)
2059 align
= max_alignment
;
2060 as_warn (_("alignment too large; %d assumed"), align
);
2065 as_warn (_("alignment negative; 0 assumed"));
2068 record_alignment (bss_seg
, align
);
2072 /* Assume some objects may require alignment on some systems. */
2073 #if defined (TC_ALPHA) && ! defined (VMS)
2076 align
= ffs (temp
) - 1;
2077 if (temp
% (1 << align
))
2084 symbolP
= symbol_find_or_make (name
);
2088 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2089 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2090 #ifdef BFD_ASSEMBLER
2091 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2092 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2094 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2097 (S_GET_SEGMENT (symbolP
) == bss_seg
2098 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2102 subseg_set (bss_seg
, 1);
2105 frag_align (align
, 0, 0);
2107 /* Detach from old frag. */
2108 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2109 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2111 symbol_set_frag (symbolP
, frag_now
);
2112 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2113 (offsetT
) temp
, (char *) 0);
2116 S_SET_SEGMENT (symbolP
, bss_seg
);
2119 /* The symbol may already have been created with a preceding
2120 ".globl" directive -- be careful not to step on storage class
2121 in that case. Otherwise, set it to static. */
2122 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2124 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2126 #endif /* OBJ_COFF */
2129 S_SET_SIZE (symbolP
, temp
);
2133 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2135 subseg_set (current_seg
, current_subseg
);
2137 demand_empty_rest_of_line ();
2141 s_lcomm (needs_align
)
2144 s_lcomm_internal (needs_align
, 0);
2148 s_lcomm_bytes (needs_align
)
2151 s_lcomm_internal (needs_align
, 1);
2156 int ignore ATTRIBUTE_UNUSED
;
2158 register char *name
;
2162 register symbolS
*symbolP
;
2164 /* We permit ANY defined expression: BSD4.2 demands constants. */
2165 name
= input_line_pointer
;
2166 c
= get_symbol_end ();
2167 p
= input_line_pointer
;
2172 as_bad (_("expected symbol name"));
2173 discard_rest_of_line ();
2179 if (*input_line_pointer
!= ',')
2182 as_bad (_("expected comma after \"%s\""), name
);
2184 ignore_rest_of_line ();
2188 input_line_pointer
++;
2191 if (exp
.X_op
!= O_constant
2192 && exp
.X_op
!= O_register
)
2194 as_bad (_("bad expression"));
2195 ignore_rest_of_line ();
2200 symbolP
= symbol_find_or_make (name
);
2202 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2203 symbolP->sy_desc == 0) out of this test because coff doesn't have
2204 those fields, and I can't see when they'd ever be tripped. I
2205 don't think I understand why they were here so I may have
2206 introduced a bug. As recently as 1.37 didn't have this test
2207 anyway. xoxorich. */
2209 if (S_GET_SEGMENT (symbolP
) == undefined_section
2210 && S_GET_VALUE (symbolP
) == 0)
2212 /* The name might be an undefined .global symbol; be sure to
2213 keep the "external" bit. */
2214 S_SET_SEGMENT (symbolP
,
2215 (exp
.X_op
== O_constant
2218 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2222 as_bad (_("symbol `%s' is already defined"), name
);
2226 demand_empty_rest_of_line ();
2229 /* Read a line into an sb. Returns the character that ended the line
2230 or zero if there are no more lines. */
2236 char quote1
, quote2
, inquote
;
2239 if (input_line_pointer
[-1] == '\n')
2240 bump_line_counters ();
2242 if (input_line_pointer
>= buffer_limit
)
2244 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2245 if (buffer_limit
== 0)
2249 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2250 code needs to be changed. */
2259 #ifdef LEX_IS_STRINGQUOTE
2265 while ((c
= * input_line_pointer
++) != 0
2266 && (!is_end_of_line
[c
]
2267 || (inquote
!= '\0' && c
!= '\n')))
2271 else if (inquote
== '\0')
2275 else if (c
== quote2
)
2279 sb_add_char (line
, c
);
2282 /* Don't skip multiple end-of-line characters, because that breaks support
2283 for the IA-64 stop bit (;;) which looks like two consecutive end-of-line
2284 characters but isn't. Instead just skip one end of line character and
2285 return the character skipped so that the caller can re-insert it if
2290 /* Define a macro. This is an interface to macro.c. */
2294 int ignore ATTRIBUTE_UNUSED
;
2303 as_where (&file
, &line
);
2306 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2307 sb_add_char (&s
, *input_line_pointer
++);
2310 if (line_label
!= NULL
)
2311 sb_add_string (&label
, S_GET_NAME (line_label
));
2313 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2315 as_bad_where (file
, line
, "%s", err
);
2318 if (line_label
!= NULL
)
2320 S_SET_SEGMENT (line_label
, undefined_section
);
2321 S_SET_VALUE (line_label
, 0);
2322 symbol_set_frag (line_label
, &zero_address_frag
);
2325 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2326 && hash_find (po_hash
, name
) != NULL
)
2329 && hash_find (po_hash
, name
+ 1) != NULL
))
2330 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2337 /* Handle the .mexit pseudo-op, which immediately exits a macro
2342 int ignore ATTRIBUTE_UNUSED
;
2344 cond_exit_macro (macro_nest
);
2345 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2348 /* Switch in and out of MRI mode. */
2352 int ignore ATTRIBUTE_UNUSED
;
2356 on
= get_absolute_expression ();
2357 old_flag
= flag_mri
;
2375 /* Operator precedence changes in m68k MRI mode, so we need to
2376 update the operator rankings. */
2377 expr_set_precedence ();
2379 #ifdef MRI_MODE_CHANGE
2381 MRI_MODE_CHANGE (on
);
2384 demand_empty_rest_of_line ();
2387 /* Handle changing the location counter. */
2390 do_org (segment
, exp
, fill
)
2395 if (segment
!= now_seg
&& segment
!= absolute_section
)
2396 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2398 if (now_seg
== absolute_section
)
2401 as_warn (_("ignoring fill value in absolute section"));
2402 if (exp
->X_op
!= O_constant
)
2404 as_bad (_("only constant offsets supported in absolute section"));
2405 exp
->X_add_number
= 0;
2407 abs_section_offset
= exp
->X_add_number
;
2412 symbolS
*sym
= exp
->X_add_symbol
;
2413 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2415 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2417 /* Handle complex expressions. */
2418 sym
= make_expr_symbol (exp
);
2422 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2429 int ignore ATTRIBUTE_UNUSED
;
2431 register segT segment
;
2433 register long temp_fill
;
2435 #ifdef md_flush_pending_output
2436 md_flush_pending_output ();
2439 /* The m68k MRI assembler has a different meaning for .org. It
2440 means to create an absolute section at a given address. We can't
2441 support that--use a linker script instead. */
2444 as_bad (_("MRI style ORG pseudo-op not supported"));
2445 ignore_rest_of_line ();
2449 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2450 thing as a sub-segment-relative origin. Any absolute origin is
2451 given a warning, then assumed to be segment-relative. Any
2452 segmented origin expression ("foo+42") had better be in the right
2453 segment or the .org is ignored.
2455 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2456 we never know sub-segment sizes when we are reading code. BSD
2457 will crash trying to emit negative numbers of filler bytes in
2458 certain .orgs. We don't crash, but see as-write for that code.
2460 Don't make frag if need_pass_2==1. */
2461 segment
= get_known_segmented_expression (&exp
);
2462 if (*input_line_pointer
== ',')
2464 input_line_pointer
++;
2465 temp_fill
= get_absolute_expression ();
2471 do_org (segment
, &exp
, temp_fill
);
2473 demand_empty_rest_of_line ();
2476 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2477 called by the obj-format routine which handles section changing
2478 when in MRI mode. It will create a new section, and return it. It
2479 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2480 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2481 flags will be set in the section. */
2485 char *type ATTRIBUTE_UNUSED
;
2495 name
= input_line_pointer
;
2496 if (!ISDIGIT (*name
))
2497 c
= get_symbol_end ();
2502 ++input_line_pointer
;
2504 while (ISDIGIT (*input_line_pointer
));
2506 c
= *input_line_pointer
;
2507 *input_line_pointer
= '\0';
2510 name
= xstrdup (name
);
2512 *input_line_pointer
= c
;
2514 seg
= subseg_new (name
, 0);
2516 if (*input_line_pointer
== ',')
2520 ++input_line_pointer
;
2521 align
= get_absolute_expression ();
2522 record_alignment (seg
, align
);
2526 if (*input_line_pointer
== ',')
2528 c
= *++input_line_pointer
;
2530 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2533 as_bad (_("unrecognized section type"));
2534 ++input_line_pointer
;
2536 #ifdef BFD_ASSEMBLER
2540 flags
= SEC_NO_FLAGS
;
2542 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2543 else if (*type
== 'D' || *type
== 'M')
2544 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2545 else if (*type
== 'R')
2546 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2547 if (flags
!= SEC_NO_FLAGS
)
2549 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2550 as_warn (_("error setting flags for \"%s\": %s"),
2551 bfd_section_name (stdoutput
, seg
),
2552 bfd_errmsg (bfd_get_error ()));
2558 /* Ignore the HP type. */
2559 if (*input_line_pointer
== ',')
2560 input_line_pointer
+= 2;
2562 demand_empty_rest_of_line ();
2564 #else /* ! TC_M68K */
2573 name
= input_line_pointer
;
2574 c
= get_symbol_end ();
2576 name
= xstrdup (name
);
2578 *input_line_pointer
= c
;
2580 seg
= subseg_new (name
, 0);
2582 if (*input_line_pointer
!= ',')
2588 ++input_line_pointer
;
2590 sectype
= input_line_pointer
;
2591 c
= get_symbol_end ();
2592 if (*sectype
== '\0')
2594 else if (strcasecmp (sectype
, "text") == 0)
2596 else if (strcasecmp (sectype
, "data") == 0)
2598 else if (strcasecmp (sectype
, "romdata") == 0)
2601 as_warn (_("unrecognized section type `%s'"), sectype
);
2602 *input_line_pointer
= c
;
2605 if (*input_line_pointer
== ',')
2609 ++input_line_pointer
;
2611 seccmd
= input_line_pointer
;
2612 c
= get_symbol_end ();
2613 if (strcasecmp (seccmd
, "absolute") == 0)
2615 as_bad (_("absolute sections are not supported"));
2616 *input_line_pointer
= c
;
2617 ignore_rest_of_line ();
2620 else if (strcasecmp (seccmd
, "align") == 0)
2624 *input_line_pointer
= c
;
2625 align
= get_absolute_expression ();
2626 record_alignment (seg
, align
);
2630 as_warn (_("unrecognized section command `%s'"), seccmd
);
2631 *input_line_pointer
= c
;
2635 demand_empty_rest_of_line ();
2637 #else /* ! TC_I960 */
2638 /* The MRI assembler seems to use different forms of .sect for
2639 different targets. */
2640 as_bad ("MRI mode not supported for this target");
2641 ignore_rest_of_line ();
2642 #endif /* ! TC_I960 */
2643 #endif /* ! TC_M68K */
2646 /* Handle the .print pseudo-op. */
2650 int ignore ATTRIBUTE_UNUSED
;
2655 s
= demand_copy_C_string (&len
);
2657 demand_empty_rest_of_line ();
2660 /* Handle the .purgem pseudo-op. */
2664 int ignore ATTRIBUTE_UNUSED
;
2666 if (is_it_end_of_statement ())
2668 demand_empty_rest_of_line ();
2678 name
= input_line_pointer
;
2679 c
= get_symbol_end ();
2680 delete_macro (name
);
2681 *input_line_pointer
= c
;
2684 while (*input_line_pointer
++ == ',');
2686 --input_line_pointer
;
2687 demand_empty_rest_of_line ();
2690 /* Handle the .rept pseudo-op. */
2694 int ignore ATTRIBUTE_UNUSED
;
2696 as_warn (_(".endr encountered without preceeding .rept, .irc, or .irp"));
2697 demand_empty_rest_of_line ();
2700 /* Handle the .rept pseudo-op. */
2704 int ignore ATTRIBUTE_UNUSED
;
2708 count
= get_absolute_expression ();
2710 do_repeat (count
, "REPT", "ENDR");
2713 /* This function provides a generic repeat block implementation. It allows
2714 different directives to be used as the start/end keys. */
2717 do_repeat (count
, start
, end
)
2726 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2728 as_bad (_("%s without %s"), start
, end
);
2734 sb_add_sb (&many
, &one
);
2738 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2740 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2743 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2744 input buffers to skip. Assumes that conditionals preceding the loop end
2745 are properly nested.
2747 This function makes it easier to implement a premature "break" out of the
2748 loop. The EXTRA arg accounts for other buffers we might have inserted,
2749 such as line substitutions. */
2755 cond_exit_macro (macro_nest
);
2756 while (extra
-- >= 0)
2757 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2760 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2761 this is .equiv, and it is an error if the symbol is already
2768 register char *name
;
2769 register char delim
;
2770 register char *end_name
;
2771 register symbolS
*symbolP
;
2773 /* Especial apologies for the random logic:
2774 this just grew, and could be parsed much more simply!
2776 name
= input_line_pointer
;
2777 delim
= get_symbol_end ();
2778 end_name
= input_line_pointer
;
2781 if (name
== end_name
)
2783 as_bad (_("expected symbol name"));
2784 discard_rest_of_line ();
2790 if (*input_line_pointer
!= ',')
2793 as_bad (_("expected comma after \"%s\""), name
);
2795 ignore_rest_of_line ();
2799 input_line_pointer
++;
2802 if (name
[0] == '.' && name
[1] == '\0')
2804 /* Turn '. = mumble' into a .org mumble. */
2805 register segT segment
;
2808 segment
= get_known_segmented_expression (&exp
);
2811 do_org (segment
, &exp
, 0);
2817 if ((symbolP
= symbol_find (name
)) == NULL
2818 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2821 /* When doing symbol listings, play games with dummy fragments living
2822 outside the normal fragment chain to record the file and line info
2824 if (listing
& LISTING_SYMBOLS
)
2826 extern struct list_info_struct
*listing_tail
;
2827 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2828 memset (dummy_frag
, 0, sizeof (fragS
));
2829 dummy_frag
->fr_type
= rs_fill
;
2830 dummy_frag
->line
= listing_tail
;
2831 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2832 dummy_frag
->fr_symbol
= symbolP
;
2836 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2839 /* "set" symbols are local unless otherwise specified. */
2840 SF_SET_LOCAL (symbolP
);
2841 #endif /* OBJ_COFF */
2844 symbol_table_insert (symbolP
);
2849 && S_IS_DEFINED (symbolP
)
2850 && S_GET_SEGMENT (symbolP
) != reg_section
)
2851 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2853 pseudo_set (symbolP
);
2854 demand_empty_rest_of_line ();
2868 #ifdef md_flush_pending_output
2869 md_flush_pending_output ();
2873 stop
= mri_comment_field (&stopc
);
2875 /* In m68k MRI mode, we need to align to a word boundary, unless
2877 if (flag_m68k_mri
&& mult
> 1)
2879 if (now_seg
== absolute_section
)
2881 abs_section_offset
+= abs_section_offset
& 1;
2882 if (line_label
!= NULL
)
2883 S_SET_VALUE (line_label
, abs_section_offset
);
2885 else if (mri_common_symbol
!= NULL
)
2889 val
= S_GET_VALUE (mri_common_symbol
);
2892 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2893 if (line_label
!= NULL
)
2895 expressionS
*symexp
;
2897 symexp
= symbol_get_value_expression (line_label
);
2898 know (symexp
->X_op
== O_symbol
);
2899 know (symexp
->X_add_symbol
== mri_common_symbol
);
2900 symexp
->X_add_number
+= 1;
2906 do_align (1, (char *) NULL
, 0, 0);
2907 if (line_label
!= NULL
)
2909 symbol_set_frag (line_label
, frag_now
);
2910 S_SET_VALUE (line_label
, frag_now_fix ());
2920 if (*input_line_pointer
== ',')
2922 ++input_line_pointer
;
2927 val
.X_op
= O_constant
;
2928 val
.X_add_number
= 0;
2931 if (val
.X_op
!= O_constant
2932 || val
.X_add_number
< - 0x80
2933 || val
.X_add_number
> 0xff
2934 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2936 if (exp
.X_op
!= O_constant
)
2937 as_bad (_("unsupported variable size or fill value"));
2944 bytes
= mult
* exp
.X_add_number
;
2945 for (i
= 0; i
< exp
.X_add_number
; i
++)
2946 emit_expr (&val
, mult
);
2951 if (exp
.X_op
== O_constant
)
2955 repeat
= exp
.X_add_number
;
2962 as_warn (_(".space repeat count is zero, ignored"));
2963 else if (repeat
< 0)
2964 as_warn (_(".space repeat count is negative, ignored"));
2968 /* If we are in the absolute section, just bump the offset. */
2969 if (now_seg
== absolute_section
)
2971 abs_section_offset
+= repeat
;
2975 /* If we are secretly in an MRI common section, then
2976 creating space just increases the size of the common
2978 if (mri_common_symbol
!= NULL
)
2980 S_SET_VALUE (mri_common_symbol
,
2981 S_GET_VALUE (mri_common_symbol
) + repeat
);
2986 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2987 (offsetT
) repeat
, (char *) 0);
2991 if (now_seg
== absolute_section
)
2993 as_bad (_("space allocation too complex in absolute section"));
2994 subseg_set (text_section
, 0);
2997 if (mri_common_symbol
!= NULL
)
2999 as_bad (_("space allocation too complex in common section"));
3000 mri_common_symbol
= NULL
;
3004 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
3005 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
3009 *p
= val
.X_add_number
;
3014 /* In MRI mode, after an odd number of bytes, we must align to an
3015 even word boundary, unless the next instruction is a dc.b, ds.b
3017 if (flag_mri
&& (bytes
& 1) != 0)
3018 mri_pending_align
= 1;
3020 demand_empty_rest_of_line ();
3023 mri_comment_end (stop
, stopc
);
3026 /* This is like s_space, but the value is a floating point number with
3027 the given precision. This is for the MRI dcb.s pseudo-op and
3031 s_float_space (float_type
)
3036 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3041 stop
= mri_comment_field (&stopc
);
3043 count
= get_absolute_expression ();
3046 if (*input_line_pointer
!= ',')
3048 as_bad (_("missing value"));
3049 ignore_rest_of_line ();
3051 mri_comment_end (stop
, stopc
);
3055 ++input_line_pointer
;
3059 /* Skip any 0{letter} that may be present. Don't even check if the
3060 * letter is legal. */
3061 if (input_line_pointer
[0] == '0'
3062 && ISALPHA (input_line_pointer
[1]))
3063 input_line_pointer
+= 2;
3065 /* Accept :xxxx, where the x's are hex digits, for a floating point
3066 with the exact digits specified. */
3067 if (input_line_pointer
[0] == ':')
3069 flen
= hex_float (float_type
, temp
);
3072 ignore_rest_of_line ();
3074 mri_comment_end (stop
, stopc
);
3082 err
= md_atof (float_type
, temp
, &flen
);
3083 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3087 as_bad (_("bad floating literal: %s"), err
);
3088 ignore_rest_of_line ();
3090 mri_comment_end (stop
, stopc
);
3095 while (--count
>= 0)
3099 p
= frag_more (flen
);
3100 memcpy (p
, temp
, (unsigned int) flen
);
3103 demand_empty_rest_of_line ();
3106 mri_comment_end (stop
, stopc
);
3109 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3113 int ignore ATTRIBUTE_UNUSED
;
3119 stop
= mri_comment_field (&stopc
);
3120 abs_section_offset
= get_absolute_expression ();
3121 subseg_set (absolute_section
, 0);
3122 demand_empty_rest_of_line ();
3124 mri_comment_end (stop
, stopc
);
3129 int ignore ATTRIBUTE_UNUSED
;
3133 temp
= get_absolute_expression ();
3134 subseg_set (text_section
, (subsegT
) temp
);
3135 demand_empty_rest_of_line ();
3137 const_flag
&= ~IN_DEFAULT_SECTION
;
3142 demand_empty_rest_of_line ()
3145 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3146 input_line_pointer
++;
3148 ignore_rest_of_line ();
3150 /* Return having already swallowed end-of-line. */
3154 ignore_rest_of_line ()
3156 /* For suspect lines: gives warning. */
3157 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3159 if (ISPRINT (*input_line_pointer
))
3160 as_warn (_("rest of line ignored; first ignored character is `%c'"),
3161 *input_line_pointer
);
3163 as_warn (_("rest of line ignored; first ignored character valued 0x%x"),
3164 *input_line_pointer
);
3166 while (input_line_pointer
< buffer_limit
3167 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3168 input_line_pointer
++;
3171 input_line_pointer
++;
3173 /* Return pointing just after end-of-line. */
3174 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3178 discard_rest_of_line ()
3180 while (input_line_pointer
< buffer_limit
3181 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3182 input_line_pointer
++;
3184 input_line_pointer
++;
3186 /* Return pointing just after end-of-line. */
3187 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3190 /* In: Pointer to a symbol.
3191 Input_line_pointer->expression.
3193 Out: Input_line_pointer->just after any whitespace after expression.
3194 Tried to set symbol to value of expression.
3195 Will change symbols type, value, and frag; */
3198 pseudo_set (symbolP
)
3202 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3204 #endif /* OBJ_AOUT or OBJ_BOUT */
3206 know (symbolP
); /* NULL pointer is logic error. */
3207 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3208 ext
= S_IS_EXTERNAL (symbolP
);
3209 #endif /* OBJ_AOUT or OBJ_BOUT */
3211 (void) expression (&exp
);
3213 if (exp
.X_op
== O_illegal
)
3214 as_bad (_("illegal expression"));
3215 else if (exp
.X_op
== O_absent
)
3216 as_bad (_("missing expression"));
3217 else if (exp
.X_op
== O_big
)
3219 if (exp
.X_add_number
> 0)
3220 as_bad (_("bignum invalid"));
3222 as_bad (_("floating point number invalid"));
3224 else if (exp
.X_op
== O_subtract
3225 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3226 && (symbol_get_frag (exp
.X_add_symbol
)
3227 == symbol_get_frag (exp
.X_op_symbol
)))
3229 exp
.X_op
= O_constant
;
3230 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3231 - S_GET_VALUE (exp
.X_op_symbol
));
3239 exp
.X_add_number
= 0;
3242 S_SET_SEGMENT (symbolP
, absolute_section
);
3243 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3245 S_SET_EXTERNAL (symbolP
);
3247 S_CLEAR_EXTERNAL (symbolP
);
3248 #endif /* OBJ_AOUT or OBJ_BOUT */
3249 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3250 if (exp
.X_op
!= O_constant
)
3251 symbol_set_frag (symbolP
, &zero_address_frag
);
3255 S_SET_SEGMENT (symbolP
, reg_section
);
3256 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3257 symbol_set_frag (symbolP
, &zero_address_frag
);
3261 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3262 || exp
.X_add_number
!= 0)
3263 symbol_set_value_expression (symbolP
, &exp
);
3264 else if (symbol_section_p (symbolP
))
3265 as_bad ("attempt to set value of section symbol");
3268 symbolS
*s
= exp
.X_add_symbol
;
3270 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3271 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3273 S_SET_EXTERNAL (symbolP
);
3275 S_CLEAR_EXTERNAL (symbolP
);
3276 #endif /* OBJ_AOUT or OBJ_BOUT */
3277 S_SET_VALUE (symbolP
,
3278 exp
.X_add_number
+ S_GET_VALUE (s
));
3279 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3280 copy_symbol_attributes (symbolP
, s
);
3285 /* The value is some complex expression.
3286 FIXME: Should we set the segment to anything? */
3287 symbol_set_value_expression (symbolP
, &exp
);
3294 CONStruct more frag of .bytes, or .words etc.
3295 Should need_pass_2 be 1 then emit no frag(s).
3296 This understands EXPRESSIONS.
3300 This has a split personality. We use expression() to read the
3301 value. We can detect if the value won't fit in a byte or word.
3302 But we can't detect if expression() discarded significant digits
3303 in the case of a long. Not worth the crocks required to fix it. */
3305 /* Select a parser for cons expressions. */
3307 /* Some targets need to parse the expression in various fancy ways.
3308 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3309 (for example, the HPPA does this). Otherwise, you can define
3310 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3311 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3312 are defined, which is the normal case, then only simple expressions
3317 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3320 #ifndef TC_PARSE_CONS_EXPRESSION
3321 #ifdef BITFIELD_CONS_EXPRESSIONS
3322 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3324 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3326 #ifdef REPEAT_CONS_EXPRESSIONS
3327 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3329 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3332 /* If we haven't gotten one yet, just call expression. */
3333 #ifndef TC_PARSE_CONS_EXPRESSION
3334 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3338 /* Worker to do .byte etc statements.
3339 Clobbers input_line_pointer and checks end-of-line. */
3342 cons_worker (nbytes
, rva
)
3343 register int nbytes
; /* 1=.byte, 2=.word, 4=.long. */
3351 #ifdef md_flush_pending_output
3352 md_flush_pending_output ();
3356 stop
= mri_comment_field (&stopc
);
3358 if (is_it_end_of_statement ())
3360 demand_empty_rest_of_line ();
3362 mri_comment_end (stop
, stopc
);
3366 #ifdef md_cons_align
3367 md_cons_align (nbytes
);
3375 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3378 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3382 if (exp
.X_op
== O_symbol
)
3383 exp
.X_op
= O_symbol_rva
;
3385 as_fatal (_("rva without symbol"));
3387 emit_expr (&exp
, (unsigned int) nbytes
);
3390 while (*input_line_pointer
++ == ',');
3392 /* In MRI mode, after an odd number of bytes, we must align to an
3393 even word boundary, unless the next instruction is a dc.b, ds.b
3395 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3396 mri_pending_align
= 1;
3398 input_line_pointer
--; /* Put terminator back into stream. */
3400 demand_empty_rest_of_line ();
3403 mri_comment_end (stop
, stopc
);
3410 cons_worker (size
, 0);
3417 cons_worker (size
, 1);
3420 /* Put the contents of expression EXP into the object file using
3421 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3424 emit_expr (exp
, nbytes
)
3426 unsigned int nbytes
;
3430 valueT extra_digit
= 0;
3432 /* Don't do anything if we are going to make another pass. */
3438 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3439 appear as a four byte positive constant in the .line section,
3440 followed by a 2 byte 0xffff. Look for that case here. */
3442 static int dwarf_line
= -1;
3444 if (strcmp (segment_name (now_seg
), ".line") != 0)
3446 else if (dwarf_line
>= 0
3448 && exp
->X_op
== O_constant
3449 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3450 listing_source_line ((unsigned int) dwarf_line
);
3451 else if (nbytes
== 4
3452 && exp
->X_op
== O_constant
3453 && exp
->X_add_number
>= 0)
3454 dwarf_line
= exp
->X_add_number
;
3459 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3460 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3461 AT_sibling (0x12) followed by a four byte address of the sibling
3462 followed by a 2 byte AT_name (0x38) followed by the name of the
3463 file. We look for that case here. */
3465 static int dwarf_file
= 0;
3467 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3469 else if (dwarf_file
== 0
3471 && exp
->X_op
== O_constant
3472 && exp
->X_add_number
== 0x11)
3474 else if (dwarf_file
== 1
3476 && exp
->X_op
== O_constant
3477 && exp
->X_add_number
== 0x12)
3479 else if (dwarf_file
== 2
3482 else if (dwarf_file
== 3
3484 && exp
->X_op
== O_constant
3485 && exp
->X_add_number
== 0x38)
3490 /* The variable dwarf_file_string tells stringer that the string
3491 may be the name of the source file. */
3492 if (dwarf_file
== 4)
3493 dwarf_file_string
= 1;
3495 dwarf_file_string
= 0;
3500 if (check_eh_frame (exp
, &nbytes
))
3505 /* Allow `.word 0' in the absolute section. */
3506 if (now_seg
== absolute_section
)
3508 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3509 as_bad (_("attempt to store value in absolute section"));
3510 abs_section_offset
+= nbytes
;
3514 /* Handle a negative bignum. */
3516 && exp
->X_add_number
== 0
3517 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3518 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3521 unsigned long carry
;
3523 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3525 /* Negate the bignum: one's complement each digit and add 1. */
3527 for (i
= 0; i
< exp
->X_add_number
; i
++)
3531 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3534 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3535 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3538 /* We can ignore any carry out, because it will be handled by
3539 extra_digit if it is needed. */
3541 extra_digit
= (valueT
) -1;
3545 if (op
== O_absent
|| op
== O_illegal
)
3547 as_warn (_("zero assumed for missing expression"));
3548 exp
->X_add_number
= 0;
3551 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3553 as_bad (_("floating point number invalid"));
3554 exp
->X_add_number
= 0;
3557 else if (op
== O_register
)
3559 as_warn (_("register value used as expression"));
3563 p
= frag_more ((int) nbytes
);
3565 #ifndef WORKING_DOT_WORD
3566 /* If we have the difference of two symbols in a word, save it on
3567 the broken_words list. See the code in write.c. */
3568 if (op
== O_subtract
&& nbytes
== 2)
3570 struct broken_word
*x
;
3572 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3573 x
->next_broken_word
= broken_words
;
3576 x
->subseg
= now_subseg
;
3578 x
->word_goes_here
= p
;
3580 x
->add
= exp
->X_add_symbol
;
3581 x
->sub
= exp
->X_op_symbol
;
3582 x
->addnum
= exp
->X_add_number
;
3590 /* If we have an integer, but the number of bytes is too large to
3591 pass to md_number_to_chars, handle it as a bignum. */
3592 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3597 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3598 extra_digit
= (valueT
) -1;
3599 val
= (valueT
) exp
->X_add_number
;
3603 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3604 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3608 op
= exp
->X_op
= O_big
;
3609 exp
->X_add_number
= gencnt
;
3612 if (op
== O_constant
)
3614 register valueT get
;
3615 register valueT use
;
3616 register valueT mask
;
3618 register valueT unmask
;
3620 /* JF << of >= number of bits in the object is undefined. In
3621 particular SPARC (Sun 4) has problems. */
3622 if (nbytes
>= sizeof (valueT
))
3625 if (nbytes
> sizeof (valueT
))
3628 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3632 /* Don't store these bits. */
3633 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3634 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3637 unmask
= ~mask
; /* Do store these bits. */
3640 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3641 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3644 get
= exp
->X_add_number
;
3646 if ((get
& mask
) != 0
3647 && ((get
& mask
) != mask
3648 || (get
& hibit
) == 0))
3649 { /* Leading bits contain both 0s & 1s. */
3650 as_warn (_("value 0x%lx truncated to 0x%lx"),
3651 (unsigned long) get
, (unsigned long) use
);
3653 /* Put bytes in right order. */
3654 md_number_to_chars (p
, use
, (int) nbytes
);
3656 else if (op
== O_big
)
3659 LITTLENUM_TYPE
*nums
;
3661 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3663 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3666 as_warn (_("bignum truncated to %d bytes"), nbytes
);
3670 if (target_big_endian
)
3672 while (nbytes
> size
)
3674 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3675 nbytes
-= CHARS_PER_LITTLENUM
;
3676 p
+= CHARS_PER_LITTLENUM
;
3679 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3680 while (size
>= CHARS_PER_LITTLENUM
)
3683 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3684 size
-= CHARS_PER_LITTLENUM
;
3685 p
+= CHARS_PER_LITTLENUM
;
3690 nums
= generic_bignum
;
3691 while (size
>= CHARS_PER_LITTLENUM
)
3693 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3695 size
-= CHARS_PER_LITTLENUM
;
3696 p
+= CHARS_PER_LITTLENUM
;
3697 nbytes
-= CHARS_PER_LITTLENUM
;
3700 while (nbytes
>= CHARS_PER_LITTLENUM
)
3702 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3703 nbytes
-= CHARS_PER_LITTLENUM
;
3704 p
+= CHARS_PER_LITTLENUM
;
3710 memset (p
, 0, nbytes
);
3712 /* Now we need to generate a fixS to record the symbol value.
3713 This is easy for BFD. For other targets it can be more
3714 complex. For very complex cases (currently, the HPPA and
3715 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3716 want. For simpler cases, you can define TC_CONS_RELOC to be
3717 the name of the reloc code that should be stored in the fixS.
3718 If neither is defined, the code uses NO_RELOC if it is
3719 defined, and otherwise uses 0. */
3721 #ifdef BFD_ASSEMBLER
3722 #ifdef TC_CONS_FIX_NEW
3723 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3726 bfd_reloc_code_real_type r
;
3743 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3747 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3752 #ifdef TC_CONS_FIX_NEW
3753 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3755 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3756 it is defined, otherwise use NO_RELOC if it is defined,
3758 #ifndef TC_CONS_RELOC
3760 #define TC_CONS_RELOC NO_RELOC
3762 #define TC_CONS_RELOC 0
3765 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3767 #endif /* TC_CONS_FIX_NEW */
3768 #endif /* BFD_ASSEMBLER */
3772 #ifdef BITFIELD_CONS_EXPRESSIONS
3774 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3775 w:x,y:z, where w and y are bitwidths and x and y are values. They
3776 then pack them all together. We do a little better in that we allow
3777 them in words, longs, etc. and we'll pack them in target byte order
3780 The rules are: pack least significat bit first, if a field doesn't
3781 entirely fit, put it in the next unit. Overflowing the bitfield is
3782 explicitly *not* even a warning. The bitwidth should be considered
3785 To use this function the tc-XXX.h file should define
3786 BITFIELD_CONS_EXPRESSIONS. */
3789 parse_bitfield_cons (exp
, nbytes
)
3791 unsigned int nbytes
;
3793 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3794 char *hold
= input_line_pointer
;
3796 (void) expression (exp
);
3798 if (*input_line_pointer
== ':')
3805 unsigned long width
;
3807 if (*input_line_pointer
!= ':')
3809 input_line_pointer
= hold
;
3811 } /* Next piece is not a bitfield. */
3813 /* In the general case, we can't allow
3814 full expressions with symbol
3815 differences and such. The relocation
3816 entries for symbols not defined in this
3817 assembly would require arbitrary field
3818 widths, positions, and masks which most
3819 of our current object formats don't
3822 In the specific case where a symbol
3823 *is* defined in this assembly, we
3824 *could* build fixups and track it, but
3825 this could lead to confusion for the
3826 backends. I'm lazy. I'll take any
3827 SEG_ABSOLUTE. I think that means that
3828 you can use a previous .set or
3829 .equ type symbol. xoxorich. */
3831 if (exp
->X_op
== O_absent
)
3833 as_warn (_("using a bit field width of zero"));
3834 exp
->X_add_number
= 0;
3835 exp
->X_op
= O_constant
;
3836 } /* Implied zero width bitfield. */
3838 if (exp
->X_op
!= O_constant
)
3840 *input_line_pointer
= '\0';
3841 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3842 *input_line_pointer
= ':';
3843 demand_empty_rest_of_line ();
3845 } /* Too complex. */
3847 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3849 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3850 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3851 width
= BITS_PER_CHAR
* nbytes
;
3854 if (width
> bits_available
)
3856 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3857 input_line_pointer
= hold
;
3858 exp
->X_add_number
= value
;
3863 hold
= ++input_line_pointer
;
3865 (void) expression (exp
);
3866 if (exp
->X_op
!= O_constant
)
3868 char cache
= *input_line_pointer
;
3870 *input_line_pointer
= '\0';
3871 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3872 *input_line_pointer
= cache
;
3873 demand_empty_rest_of_line ();
3875 } /* Too complex. */
3877 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3878 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3880 if ((bits_available
-= width
) == 0
3881 || is_it_end_of_statement ()
3882 || *input_line_pointer
!= ',')
3885 } /* All the bitfields we're gonna get. */
3887 hold
= ++input_line_pointer
;
3888 (void) expression (exp
);
3891 exp
->X_add_number
= value
;
3892 exp
->X_op
= O_constant
;
3893 exp
->X_unsigned
= 1;
3897 #endif /* BITFIELD_CONS_EXPRESSIONS */
3899 /* Handle an MRI style string expression. */
3903 parse_mri_cons (exp
, nbytes
)
3905 unsigned int nbytes
;
3907 if (*input_line_pointer
!= '\''
3908 && (input_line_pointer
[1] != '\''
3909 || (*input_line_pointer
!= 'A'
3910 && *input_line_pointer
!= 'E')))
3911 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3915 unsigned int result
= 0;
3917 /* An MRI style string. Cut into as many bytes as will fit into
3918 a nbyte chunk, left justify if necessary, and separate with
3919 commas so we can try again later. */
3920 if (*input_line_pointer
== 'A')
3921 ++input_line_pointer
;
3922 else if (*input_line_pointer
== 'E')
3924 as_bad (_("EBCDIC constants are not supported"));
3925 ++input_line_pointer
;
3928 input_line_pointer
++;
3929 for (scan
= 0; scan
< nbytes
; scan
++)
3931 if (*input_line_pointer
== '\'')
3933 if (input_line_pointer
[1] == '\'')
3935 input_line_pointer
++;
3940 result
= (result
<< 8) | (*input_line_pointer
++);
3944 while (scan
< nbytes
)
3950 /* Create correct expression. */
3951 exp
->X_op
= O_constant
;
3952 exp
->X_add_number
= result
;
3954 /* Fake it so that we can read the next char too. */
3955 if (input_line_pointer
[0] != '\'' ||
3956 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3958 input_line_pointer
-= 2;
3959 input_line_pointer
[0] = ',';
3960 input_line_pointer
[1] = '\'';
3963 input_line_pointer
++;
3966 #endif /* TC_M68K */
3968 #ifdef REPEAT_CONS_EXPRESSIONS
3970 /* Parse a repeat expression for cons. This is used by the MIPS
3971 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3972 object file COUNT times.
3974 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3977 parse_repeat_cons (exp
, nbytes
)
3979 unsigned int nbytes
;
3986 if (*input_line_pointer
!= ':')
3988 /* No repeat count. */
3992 ++input_line_pointer
;
3993 expression (&count
);
3994 if (count
.X_op
!= O_constant
3995 || count
.X_add_number
<= 0)
3997 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4001 /* The cons function is going to output this expression once. So we
4002 output it count - 1 times. */
4003 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
4004 emit_expr (exp
, nbytes
);
4007 #endif /* REPEAT_CONS_EXPRESSIONS */
4009 /* Parse a floating point number represented as a hex constant. This
4010 permits users to specify the exact bits they want in the floating
4014 hex_float (float_type
, bytes
)
4048 as_bad (_("unknown floating type type '%c'"), float_type
);
4052 /* It would be nice if we could go through expression to parse the
4053 hex constant, but if we get a bignum it's a pain to sort it into
4054 the buffer correctly. */
4056 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4060 /* The MRI assembler accepts arbitrary underscores strewn about
4061 through the hex constant, so we ignore them as well. */
4062 if (*input_line_pointer
== '_')
4064 ++input_line_pointer
;
4070 as_warn (_("floating point constant too large"));
4073 d
= hex_value (*input_line_pointer
) << 4;
4074 ++input_line_pointer
;
4075 while (*input_line_pointer
== '_')
4076 ++input_line_pointer
;
4077 if (hex_p (*input_line_pointer
))
4079 d
+= hex_value (*input_line_pointer
);
4080 ++input_line_pointer
;
4082 if (target_big_endian
)
4085 bytes
[length
- i
- 1] = d
;
4091 if (target_big_endian
)
4092 memset (bytes
+ i
, 0, length
- i
);
4094 memset (bytes
, 0, length
- i
);
4102 CONStruct some more frag chars of .floats .ffloats etc.
4103 Makes 0 or more new frags.
4104 If need_pass_2 == 1, no frags are emitted.
4105 This understands only floating literals, not expressions. Sorry.
4107 A floating constant is defined by atof_generic(), except it is preceded
4108 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4109 reading, I decided to be incompatible. This always tries to give you
4110 rounded bits to the precision of the pseudo-op. Former AS did premature
4111 truncatation, restored noisy bits instead of trailing 0s AND gave you
4112 a choice of 2 flavours of noise according to which of 2 floating-point
4113 scanners you directed AS to use.
4115 In: input_line_pointer->whitespace before, or '0' of flonum. */
4118 float_cons (float_type
)
4119 /* Clobbers input_line-pointer, checks end-of-line. */
4120 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4123 int length
; /* Number of chars in an object. */
4124 register char *err
; /* Error from scanning floating literal. */
4125 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4127 if (is_it_end_of_statement ())
4129 demand_empty_rest_of_line ();
4133 #ifdef md_flush_pending_output
4134 md_flush_pending_output ();
4139 /* input_line_pointer->1st char of a flonum (we hope!). */
4142 /* Skip any 0{letter} that may be present. Don't even check if the
4143 letter is legal. Someone may invent a "z" format and this routine
4144 has no use for such information. Lusers beware: you get
4145 diagnostics if your input is ill-conditioned. */
4146 if (input_line_pointer
[0] == '0'
4147 && ISALPHA (input_line_pointer
[1]))
4148 input_line_pointer
+= 2;
4150 /* Accept :xxxx, where the x's are hex digits, for a floating
4151 point with the exact digits specified. */
4152 if (input_line_pointer
[0] == ':')
4154 ++input_line_pointer
;
4155 length
= hex_float (float_type
, temp
);
4158 ignore_rest_of_line ();
4164 err
= md_atof (float_type
, temp
, &length
);
4165 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4169 as_bad (_("bad floating literal: %s"), err
);
4170 ignore_rest_of_line ();
4181 #ifdef REPEAT_CONS_EXPRESSIONS
4182 if (*input_line_pointer
== ':')
4184 expressionS count_exp
;
4186 ++input_line_pointer
;
4187 expression (&count_exp
);
4189 if (count_exp
.X_op
!= O_constant
4190 || count_exp
.X_add_number
<= 0)
4191 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4193 count
= count_exp
.X_add_number
;
4197 while (--count
>= 0)
4199 p
= frag_more (length
);
4200 memcpy (p
, temp
, (unsigned int) length
);
4205 while (*input_line_pointer
++ == ',');
4207 /* Put terminator back into stream. */
4208 --input_line_pointer
;
4209 demand_empty_rest_of_line ();
4212 /* Return the size of a LEB128 value. */
4215 sizeof_sleb128 (value
)
4218 register int size
= 0;
4219 register unsigned byte
;
4223 byte
= (value
& 0x7f);
4224 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4225 Fortunately, we can structure things so that the extra work reduces
4226 to a noop on systems that do things "properly". */
4227 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4230 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4231 || ((value
== -1) && ((byte
& 0x40) != 0))));
4237 sizeof_uleb128 (value
)
4240 register int size
= 0;
4241 register unsigned byte
;
4245 byte
= (value
& 0x7f);
4255 sizeof_leb128 (value
, sign
)
4260 return sizeof_sleb128 ((offsetT
) value
);
4262 return sizeof_uleb128 (value
);
4265 /* Output a LEB128 value. */
4268 output_sleb128 (p
, value
)
4272 register char *orig
= p
;
4277 unsigned byte
= (value
& 0x7f);
4279 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4280 Fortunately, we can structure things so that the extra work reduces
4281 to a noop on systems that do things "properly". */
4282 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4284 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4285 || ((value
== -1) && ((byte
& 0x40) != 0))));
4297 output_uleb128 (p
, value
)
4305 unsigned byte
= (value
& 0x7f);
4308 /* More bytes to follow. */
4319 output_leb128 (p
, value
, sign
)
4325 return output_sleb128 (p
, (offsetT
) value
);
4327 return output_uleb128 (p
, value
);
4330 /* Do the same for bignums. We combine sizeof with output here in that
4331 we don't output for NULL values of P. It isn't really as critical as
4332 for "normal" values that this be streamlined. */
4335 output_big_sleb128 (p
, bignum
, size
)
4337 LITTLENUM_TYPE
*bignum
;
4345 /* Strip leading sign extensions off the bignum. */
4346 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4351 if (loaded
< 7 && size
> 0)
4353 val
|= (*bignum
<< loaded
);
4354 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4365 if ((val
== 0 && (byte
& 0x40) == 0)
4366 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4367 && (byte
& 0x40) != 0))
4375 while (byte
& 0x80);
4381 output_big_uleb128 (p
, bignum
, size
)
4383 LITTLENUM_TYPE
*bignum
;
4391 /* Strip leading zeros off the bignum. */
4392 /* XXX: Is this needed? */
4393 while (size
> 0 && bignum
[size
- 1] == 0)
4398 if (loaded
< 7 && size
> 0)
4400 val
|= (*bignum
<< loaded
);
4401 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4410 if (size
> 0 || val
)
4417 while (byte
& 0x80);
4423 output_big_leb128 (p
, bignum
, size
, sign
)
4425 LITTLENUM_TYPE
*bignum
;
4429 return output_big_sleb128 (p
, bignum
, size
);
4431 return output_big_uleb128 (p
, bignum
, size
);
4434 /* Generate the appropriate fragments for a given expression to emit a
4438 emit_leb128_expr (exp
, sign
)
4442 operatorT op
= exp
->X_op
;
4445 if (op
== O_absent
|| op
== O_illegal
)
4447 as_warn (_("zero assumed for missing expression"));
4448 exp
->X_add_number
= 0;
4451 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4453 as_bad (_("floating point number invalid"));
4454 exp
->X_add_number
= 0;
4457 else if (op
== O_register
)
4459 as_warn (_("register value used as expression"));
4463 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
4464 a signal that this is leb128 data. It shouldn't optimize this away. */
4466 if (check_eh_frame (exp
, &nbytes
))
4469 /* Let the backend know that subsequent data may be byte aligned. */
4470 #ifdef md_cons_align
4474 if (op
== O_constant
)
4476 /* If we've got a constant, emit the thing directly right now. */
4478 valueT value
= exp
->X_add_number
;
4482 size
= sizeof_leb128 (value
, sign
);
4483 p
= frag_more (size
);
4484 output_leb128 (p
, value
, sign
);
4486 else if (op
== O_big
)
4488 /* O_big is a different sort of constant. */
4493 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4494 p
= frag_more (size
);
4495 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4499 /* Otherwise, we have to create a variable sized fragment and
4500 resolve things later. */
4502 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4503 make_expr_symbol (exp
), 0, (char *) NULL
);
4507 /* Parse the .sleb128 and .uleb128 pseudos. */
4518 emit_leb128_expr (&exp
, sign
);
4520 while (*input_line_pointer
++ == ',');
4522 input_line_pointer
--;
4523 demand_empty_rest_of_line ();
4526 /* We read 0 or more ',' separated, double-quoted strings.
4527 Caller should have checked need_pass_2 is FALSE because we don't
4531 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4532 /* Checks end-of-line. */
4533 register int append_zero
; /* 0: don't append '\0', else 1. */
4535 register unsigned int c
;
4538 #ifdef md_flush_pending_output
4539 md_flush_pending_output ();
4542 /* The following awkward logic is to parse ZERO or more strings,
4543 comma separated. Recall a string expression includes spaces
4544 before the opening '\"' and spaces after the closing '\"'.
4545 We fake a leading ',' if there is (supposed to be)
4546 a 1st, expression. We keep demanding expressions for each ','. */
4547 if (is_it_end_of_statement ())
4549 c
= 0; /* Skip loop. */
4550 ++input_line_pointer
; /* Compensate for end of loop. */
4554 c
= ','; /* Do loop. */
4556 /* If we have been switched into the abs_section then we
4557 will not have an obstack onto which we can hang strings. */
4558 if (now_seg
== absolute_section
)
4560 as_bad (_("strings must be placed into a section"));
4562 ignore_rest_of_line ();
4565 while (c
== ',' || c
== '<' || c
== '"')
4568 switch (*input_line_pointer
)
4571 ++input_line_pointer
; /*->1st char of string. */
4572 start
= input_line_pointer
;
4573 while (is_a_char (c
= next_char_of_string ()))
4575 FRAG_APPEND_1_CHAR (c
);
4579 FRAG_APPEND_1_CHAR (0);
4581 know (input_line_pointer
[-1] == '\"');
4585 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4586 will emit .string with a filename in the .debug section
4587 after a sequence of constants. See the comment in
4588 emit_expr for the sequence. emit_expr will set
4589 dwarf_file_string to non-zero if this string might be a
4590 source file name. */
4591 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4592 dwarf_file_string
= 0;
4593 else if (dwarf_file_string
)
4595 c
= input_line_pointer
[-1];
4596 input_line_pointer
[-1] = '\0';
4597 listing_source_file (start
);
4598 input_line_pointer
[-1] = c
;
4605 input_line_pointer
++;
4606 c
= get_single_number ();
4607 FRAG_APPEND_1_CHAR (c
);
4608 if (*input_line_pointer
!= '>')
4610 as_bad (_("expected <nn>"));
4612 input_line_pointer
++;
4615 input_line_pointer
++;
4619 c
= *input_line_pointer
;
4622 demand_empty_rest_of_line ();
4625 /* FIXME-SOMEDAY: I had trouble here on characters with the
4626 high bits set. We'll probably also have trouble with
4627 multibyte chars, wide chars, etc. Also be careful about
4628 returning values bigger than 1 byte. xoxorich. */
4631 next_char_of_string ()
4633 register unsigned int c
;
4635 c
= *input_line_pointer
++ & CHAR_MASK
;
4643 as_warn (_("unterminated string; newline inserted"));
4644 bump_line_counters ();
4647 #ifndef NO_STRING_ESCAPES
4649 switch (c
= *input_line_pointer
++)
4677 break; /* As itself. */
4693 for (i
= 0, number
= 0;
4694 ISDIGIT (c
) && i
< 3;
4695 c
= *input_line_pointer
++, i
++)
4697 number
= number
* 8 + c
- '0';
4702 --input_line_pointer
;
4711 c
= *input_line_pointer
++;
4712 while (ISXDIGIT (c
))
4715 number
= number
* 16 + c
- '0';
4716 else if (ISUPPER (c
))
4717 number
= number
* 16 + c
- 'A' + 10;
4719 number
= number
* 16 + c
- 'a' + 10;
4720 c
= *input_line_pointer
++;
4723 --input_line_pointer
;
4728 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4729 as_warn (_("unterminated string; newline inserted"));
4731 bump_line_counters ();
4736 #ifdef ONLY_STANDARD_ESCAPES
4737 as_bad (_("bad escaped character in string"));
4739 #endif /* ONLY_STANDARD_ESCAPES */
4744 #endif /* ! defined (NO_STRING_ESCAPES) */
4753 get_segmented_expression (expP
)
4754 register expressionS
*expP
;
4756 register segT retval
;
4758 retval
= expression (expP
);
4759 if (expP
->X_op
== O_illegal
4760 || expP
->X_op
== O_absent
4761 || expP
->X_op
== O_big
)
4763 as_bad (_("expected address expression"));
4764 expP
->X_op
= O_constant
;
4765 expP
->X_add_number
= 0;
4766 retval
= absolute_section
;
4772 get_known_segmented_expression (expP
)
4773 register expressionS
*expP
;
4775 register segT retval
;
4777 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4779 /* There is no easy way to extract the undefined symbol from the
4781 if (expP
->X_add_symbol
!= NULL
4782 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4783 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4784 S_GET_NAME (expP
->X_add_symbol
));
4786 as_warn (_("some symbol undefined; zero assumed"));
4787 retval
= absolute_section
;
4788 expP
->X_op
= O_constant
;
4789 expP
->X_add_number
= 0;
4791 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4796 get_absolute_expr (exp
)
4800 if (exp
->X_op
!= O_constant
)
4802 if (exp
->X_op
!= O_absent
)
4803 as_bad (_("bad or irreducible absolute expression"));
4804 exp
->X_add_number
= 0;
4806 return exp
->X_add_number
;
4810 get_absolute_expression ()
4814 return get_absolute_expr (&exp
);
4817 char /* Return terminator. */
4818 get_absolute_expression_and_terminator (val_pointer
)
4819 long *val_pointer
; /* Return value of expression. */
4821 /* FIXME: val_pointer should probably be offsetT *. */
4822 *val_pointer
= (long) get_absolute_expression ();
4823 return (*input_line_pointer
++);
4826 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4827 Give a warning if that happens. */
4830 demand_copy_C_string (len_pointer
)
4835 if ((s
= demand_copy_string (len_pointer
)) != 0)
4839 for (len
= *len_pointer
; len
> 0; len
--)
4846 as_bad (_("this string may not contain \'\\0\'"));
4854 /* Demand string, but return a safe (=private) copy of the string.
4855 Return NULL if we can't read a string here. */
4858 demand_copy_string (lenP
)
4861 register unsigned int c
;
4867 if (*input_line_pointer
== '\"')
4869 input_line_pointer
++; /* Skip opening quote. */
4871 while (is_a_char (c
= next_char_of_string ()))
4873 obstack_1grow (¬es
, c
);
4876 /* JF this next line is so demand_copy_C_string will return a
4877 null terminated string. */
4878 obstack_1grow (¬es
, '\0');
4879 retval
= obstack_finish (¬es
);
4883 as_warn (_("missing string"));
4885 ignore_rest_of_line ();
4891 /* In: Input_line_pointer->next character.
4893 Do: Skip input_line_pointer over all whitespace.
4895 Out: 1 if input_line_pointer->end-of-line. */
4898 is_it_end_of_statement ()
4901 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4905 equals (sym_name
, reassign
)
4909 register symbolS
*symbolP
; /* Symbol we are working with. */
4913 input_line_pointer
++;
4914 if (*input_line_pointer
== '=')
4915 input_line_pointer
++;
4917 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4918 input_line_pointer
++;
4921 stop
= mri_comment_field (&stopc
);
4923 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4925 /* Turn '. = mumble' into a .org mumble. */
4926 register segT segment
;
4929 segment
= get_known_segmented_expression (&exp
);
4931 do_org (segment
, &exp
, 0);
4938 symbolP
= symbol_find (sym_name
);
4939 local
= symbolP
== NULL
;
4941 #endif /* OBJ_COFF */
4942 symbolP
= symbol_find_or_make (sym_name
);
4943 /* Permit register names to be redefined. */
4945 && S_IS_DEFINED (symbolP
)
4946 && S_GET_SEGMENT (symbolP
) != reg_section
)
4947 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
4950 /* "set" symbols are local unless otherwise specified. */
4952 SF_SET_LOCAL (symbolP
);
4953 #endif /* OBJ_COFF */
4955 pseudo_set (symbolP
);
4960 /* Check garbage after the expression. */
4961 ignore_rest_of_line ();
4962 mri_comment_end (stop
, stopc
);
4966 /* .incbin -- include a file verbatim at the current location. */
4970 int x ATTRIBUTE_UNUSED
;
4981 #ifdef md_flush_pending_output
4982 md_flush_pending_output ();
4986 filename
= demand_copy_string (& len
);
4987 if (filename
== NULL
)
4992 /* Look for optional skip and count. */
4993 if (* input_line_pointer
== ',')
4995 ++ input_line_pointer
;
4996 skip
= get_absolute_expression ();
5000 if (* input_line_pointer
== ',')
5002 ++ input_line_pointer
;
5004 count
= get_absolute_expression ();
5006 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
5012 demand_empty_rest_of_line ();
5014 /* Try opening absolute path first, then try include dirs. */
5015 binfile
= fopen (filename
, FOPEN_RB
);
5016 if (binfile
== NULL
)
5020 path
= xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
5022 for (i
= 0; i
< include_dir_count
; i
++)
5024 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
5026 binfile
= fopen (path
, FOPEN_RB
);
5027 if (binfile
!= NULL
)
5031 if (binfile
== NULL
)
5032 as_bad (_("file not found: %s"), filename
);
5035 path
= xstrdup (filename
);
5041 register_dependency (path
);
5043 /* Compute the length of the file. */
5044 if (fseek (binfile
, 0, SEEK_END
) != 0)
5046 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
5049 file_len
= ftell (binfile
);
5051 /* If a count was not specified use the size of the file. */
5055 if (skip
+ count
> file_len
)
5057 as_bad (_("skip (%ld) + count (%ld) larger than file size (%ld)"),
5058 skip
, count
, file_len
);
5062 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
5064 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
5068 /* Allocate frag space and store file contents in it. */
5069 binfrag
= frag_more (count
);
5071 bytes
= fread (binfrag
, 1, count
, binfile
);
5073 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5074 path
, bytes
, count
);
5077 if (binfile
!= NULL
)
5083 /* .include -- include a file at this point. */
5087 int arg ATTRIBUTE_UNUSED
;
5096 filename
= demand_copy_string (&i
);
5097 if (filename
== NULL
)
5099 /* demand_copy_string has already printed an error and
5100 called ignore_rest_of_line. */
5108 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5109 && *input_line_pointer
!= ' '
5110 && *input_line_pointer
!= '\t')
5112 obstack_1grow (¬es
, *input_line_pointer
);
5113 ++input_line_pointer
;
5117 obstack_1grow (¬es
, '\0');
5118 filename
= obstack_finish (¬es
);
5119 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5120 ++input_line_pointer
;
5123 demand_empty_rest_of_line ();
5124 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
5126 for (i
= 0; i
< include_dir_count
; i
++)
5128 strcpy (path
, include_dirs
[i
]);
5130 strcat (path
, filename
);
5131 if (0 != (try = fopen (path
, FOPEN_RT
)))
5141 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5142 register_dependency (path
);
5143 input_scrub_insert_file (path
);
5147 add_include_dir (path
)
5152 if (include_dir_count
== 0)
5154 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5155 include_dirs
[0] = "."; /* Current dir. */
5156 include_dir_count
= 2;
5160 include_dir_count
++;
5162 (char **) realloc (include_dirs
,
5163 include_dir_count
* sizeof (*include_dirs
));
5166 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5169 if (i
> include_dir_maxlen
)
5170 include_dir_maxlen
= i
;
5173 /* Output debugging information to denote the source file. */
5176 generate_file_debug ()
5178 if (debug_type
== DEBUG_STABS
)
5179 stabs_generate_asm_file ();
5182 /* Output line number debugging information for the current source line. */
5185 generate_lineno_debug ()
5189 case DEBUG_UNSPECIFIED
:
5194 stabs_generate_asm_lineno ();
5197 ecoff_generate_asm_lineno ();
5200 /* ??? We could here indicate to dwarf2dbg.c that something
5201 has changed. However, since there is additional backend
5202 support that is required (calling dwarf2_emit_insn), we
5203 let dwarf2dbg.c call as_where on its own. */
5208 /* Output debugging information to mark a function entry point or end point.
5209 END_P is zero for .func, and non-zero for .endfunc. */
5215 do_s_func (end_p
, NULL
);
5218 /* Subroutine of s_func so targets can choose a different default prefix.
5219 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5222 do_s_func (end_p
, default_prefix
)
5224 const char *default_prefix
;
5226 /* Record the current function so that we can issue an error message for
5227 misplaced .func,.endfunc, and also so that .endfunc needs no
5229 static char *current_name
;
5230 static char *current_label
;
5234 if (current_name
== NULL
)
5236 as_bad (_("missing .func"));
5237 ignore_rest_of_line ();
5241 if (debug_type
== DEBUG_STABS
)
5242 stabs_generate_asm_endfunc (current_name
, current_label
);
5244 current_name
= current_label
= NULL
;
5249 char delim1
, delim2
;
5251 if (current_name
!= NULL
)
5253 as_bad (_(".endfunc missing for previous .func"));
5254 ignore_rest_of_line ();
5258 name
= input_line_pointer
;
5259 delim1
= get_symbol_end ();
5260 name
= xstrdup (name
);
5261 *input_line_pointer
= delim1
;
5263 if (*input_line_pointer
!= ',')
5266 asprintf (&label
, "%s%s", default_prefix
, name
);
5269 char leading_char
= 0;
5270 #ifdef BFD_ASSEMBLER
5271 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5273 /* Missing entry point, use function's name with the leading
5276 asprintf (&label
, "%c%s", leading_char
, name
);
5283 ++input_line_pointer
;
5285 label
= input_line_pointer
;
5286 delim2
= get_symbol_end ();
5287 label
= xstrdup (label
);
5288 *input_line_pointer
= delim2
;
5291 if (debug_type
== DEBUG_STABS
)
5292 stabs_generate_asm_func (name
, label
);
5294 current_name
= name
;
5295 current_label
= label
;
5298 demand_empty_rest_of_line ();
5303 int arg ATTRIBUTE_UNUSED
;
5305 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5307 ++input_line_pointer
;
5309 ++input_line_pointer
;
5313 read_print_statistics (file
)
5316 hash_print_statistics (file
, "pseudo-op table", po_hash
);
5319 /* Inserts the given line into the input stream.
5321 This call avoids macro/conditionals nesting checking, since the contents of
5322 the line are assumed to replace the contents of a line already scanned.
5324 An appropriate use of this function would be substition of input lines when
5325 called by md_start_line_hook(). The given line is assumed to already be
5326 properly scrubbed. */
5329 input_scrub_insert_line (line
)
5334 sb_add_string (&newline
, line
);
5335 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
5337 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
5340 /* Insert a file into the input stream; the path must resolve to an actual
5341 file; no include path searching or dependency registering is performed. */
5344 input_scrub_insert_file (path
)
5347 input_scrub_include_file (path
, input_line_pointer
);
5348 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);