1 /* read.c - read a source file -
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* If your chars aren't 8 bits, you will change this a bit.
24 But then, GNU isn't spozed to run on your machine anyway.
25 (RMS is so shortsighted sometimes.) */
26 #define MASK_CHAR (0xFF)
28 #define MASK_CHAR ((int)(unsigned char) -1)
31 /* This is the largest known floating point format (for now). It will
32 grow when we do 4361 style flonums. */
33 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
35 /* Routines that read assembler source text to build spagetti in memory.
36 Another group of these functions is in the expr.c module. */
39 #include "safe-ctype.h"
47 #ifndef TC_START_LABEL
48 #define TC_START_LABEL(x,y) (x == ':')
51 /* Set by the object-format or the target. */
52 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
53 #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
58 else if ((SIZE) >= 4) \
60 else if ((SIZE) >= 2) \
68 char *input_line_pointer
; /*->next char of source file to parse. */
70 #if BITS_PER_CHAR != 8
71 /* The following table is indexed by[(char)] and will break if
72 a char does not have exactly 256 states (hopefully 0:255!)! */
77 /* The m88k unfortunately uses @ as a label beginner. */
82 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
87 /* The Delta 68k assembler permits % inside label names. */
92 /* The PowerPC Windows NT assemblers permits ? inside label names. */
97 /* The IA-64 assembler uses # as a suffix designating a symbol. We include
98 it in the symbol and strip it out in tc_canonicalize_symbol_name. */
103 /* The a29k assembler does not permits labels to start with $. */
108 /* The Delta 68k assembler permits ~ at start of label names. */
112 /* Used by is_... macros. our ctype[]. */
113 char lex_type
[256] = {
114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
116 0, 0, 0, LEX_HASH
, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
117 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
118 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
119 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
120 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
121 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
122 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
123 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
124 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
125 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
126 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
127 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
128 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
129 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
133 Out: 1 if this character ends a line. */
134 char is_end_of_line
[256] = {
136 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, /* @abcdefghijklmno */
138 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* @abcdefghijklmno */
140 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
141 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* _!"#$%&'()*+,-./ */
142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
145 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
146 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
149 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
150 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* */
157 #ifdef IGNORE_OPCODE_CASE
158 char original_case_string
[128];
161 /* Functions private to this file. */
163 static char *buffer
; /* 1st char of each buffer of lines is here. */
164 static char *buffer_limit
; /*->1 + last char in buffer. */
166 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
167 in the tc-<CPU>.h file. See the "Porting GAS" section of the
169 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
171 static char *old_buffer
; /* JF a hack. */
172 static char *old_input
;
173 static char *old_limit
;
175 /* Variables for handling include file directory table. */
177 /* Table of pointers to directories to search for .include's. */
180 /* How many are in the table. */
181 int include_dir_count
;
183 /* Length of longest in table. */
184 int include_dir_maxlen
= 1;
186 #ifndef WORKING_DOT_WORD
187 struct broken_word
*broken_words
;
188 int new_broken_words
;
191 /* The current offset into the absolute section. We don't try to
192 build frags in the absolute section, since no data can be stored
193 there. We just keep track of the current offset. */
194 addressT abs_section_offset
;
196 /* If this line had an MRI style label, it is stored in this variable.
197 This is used by some of the MRI pseudo-ops. */
200 /* This global variable is used to support MRI common sections. We
201 translate such sections into a common symbol. This variable is
202 non-NULL when we are in an MRI common section. */
203 symbolS
*mri_common_symbol
;
205 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
206 need to align to an even byte boundary unless the next pseudo-op is
207 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
209 static int mri_pending_align
;
213 /* This variable is set to be non-zero if the next string we see might
214 be the name of the source file in DWARF debugging information. See
215 the comment in emit_expr for the format we look for. */
216 static int dwarf_file_string
;
220 static void cons_worker
PARAMS ((int, int));
221 static int scrub_from_string
PARAMS ((char *, int));
222 static void do_align
PARAMS ((int, char *, int, int));
223 static void s_align
PARAMS ((int, int));
224 static void s_lcomm_internal
PARAMS ((int, int));
225 static int hex_float
PARAMS ((int, char *));
226 static inline int sizeof_sleb128
PARAMS ((offsetT
));
227 static inline int sizeof_uleb128
PARAMS ((valueT
));
228 static inline int output_sleb128
PARAMS ((char *, offsetT
));
229 static inline int output_uleb128
PARAMS ((char *, valueT
));
230 static inline int output_big_sleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
231 static inline int output_big_uleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
232 static int output_big_leb128
PARAMS ((char *, LITTLENUM_TYPE
*, int, int));
233 static void do_org
PARAMS ((segT
, expressionS
*, int));
234 char *demand_copy_string
PARAMS ((int *lenP
));
235 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
236 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
237 static void pobegin
PARAMS ((void));
238 static int get_line_sb
PARAMS ((sb
*));
239 static void generate_file_debug
PARAMS ((void));
247 obj_read_begin_hook ();
249 /* Something close -- but not too close -- to a multiple of 1024.
250 The debugging malloc I'm using has 24 bytes of overhead. */
251 obstack_begin (¬es
, chunksize
);
252 obstack_begin (&cond_obstack
, chunksize
);
254 /* Use machine dependent syntax. */
255 for (p
= line_separator_chars
; *p
; p
++)
256 is_end_of_line
[(unsigned char) *p
] = 1;
257 /* Use more. FIXME-SOMEDAY. */
263 /* Set up pseudo-op tables. */
265 static struct hash_control
*po_hash
;
267 static const pseudo_typeS potable
[] = {
268 {"abort", s_abort
, 0},
269 {"align", s_align_ptwo
, 0},
270 {"ascii", stringer
, 0},
271 {"asciz", stringer
, 1},
272 {"balign", s_align_bytes
, 0},
273 {"balignw", s_align_bytes
, -2},
274 {"balignl", s_align_bytes
, -4},
278 {"common", s_mri_common
, 0},
279 {"common.s", s_mri_common
, 1},
283 {"dc.d", float_cons
, 'd'},
285 {"dc.s", float_cons
, 'f'},
287 {"dc.x", float_cons
, 'x'},
289 {"dcb.b", s_space
, 1},
290 {"dcb.d", s_float_space
, 'd'},
291 {"dcb.l", s_space
, 4},
292 {"dcb.s", s_float_space
, 'f'},
293 {"dcb.w", s_space
, 2},
294 {"dcb.x", s_float_space
, 'x'},
296 {"ds.b", s_space
, 1},
297 {"ds.d", s_space
, 8},
298 {"ds.l", s_space
, 4},
299 {"ds.p", s_space
, 12},
300 {"ds.s", s_space
, 4},
301 {"ds.w", s_space
, 2},
302 {"ds.x", s_space
, 12},
303 {"debug", s_ignore
, 0},
308 {"double", float_cons
, 'd'},
310 {"eject", listing_eject
, 0}, /* Formfeed listing. */
312 {"elsec", s_else
, 0},
313 {"elseif", s_elseif
, (int) O_ne
},
315 {"endc", s_endif
, 0},
316 {"endfunc", s_func
, 1},
317 {"endif", s_endif
, 0},
318 {"endr", s_bad_endr
, 0},
323 {"exitm", s_mexit
, 0},
325 {"extern", s_ignore
, 0}, /* We treat all undef as ext. */
326 {"appfile", s_app_file
, 1},
327 {"appline", s_app_line
, 0},
329 {"file", s_app_file
, 0},
331 {"float", float_cons
, 'f'},
332 {"format", s_ignore
, 0},
334 {"global", s_globl
, 0},
335 {"globl", s_globl
, 0},
337 {"if", s_if
, (int) O_ne
},
339 {"ifdef", s_ifdef
, 0},
340 {"ifeq", s_if
, (int) O_eq
},
341 {"ifeqs", s_ifeqs
, 0},
342 {"ifge", s_if
, (int) O_ge
},
343 {"ifgt", s_if
, (int) O_gt
},
344 {"ifle", s_if
, (int) O_le
},
345 {"iflt", s_if
, (int) O_lt
},
347 {"ifndef", s_ifdef
, 1},
348 {"ifne", s_if
, (int) O_ne
},
349 {"ifnes", s_ifeqs
, 1},
350 {"ifnotdef", s_ifdef
, 1},
351 {"incbin", s_incbin
, 0},
352 {"include", s_include
, 0},
358 {"lcomm", s_lcomm
, 0},
359 {"lflags", listing_flags
, 0}, /* Listing flags. */
360 {"linkonce", s_linkonce
, 0},
361 {"list", listing_list
, 1}, /* Turn listing on. */
362 {"llen", listing_psize
, 1},
365 {"macro", s_macro
, 0},
366 {"mexit", s_mexit
, 0},
368 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
369 {"name", s_ignore
, 0},
370 {"noformat", s_ignore
, 0},
371 {"nolist", listing_list
, 0}, /* Turn listing off. */
372 {"nopage", listing_nopage
, 0},
374 {"offset", s_struct
, 0},
376 {"p2align", s_align_ptwo
, 0},
377 {"p2alignw", s_align_ptwo
, -2},
378 {"p2alignl", s_align_ptwo
, -4},
379 {"page", listing_eject
, 0},
380 {"plen", listing_psize
, 0},
381 {"print", s_print
, 0},
382 {"psize", listing_psize
, 0}, /* Set paper size. */
383 {"purgem", s_purgem
, 0},
388 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
393 {"single", float_cons
, 'f'},
395 {"space", s_space
, 0},
396 {"skip", s_space
, 0},
397 {"sleb128", s_leb128
, 1},
398 {"spc", s_ignore
, 0},
399 {"stabd", s_stab
, 'd'},
400 {"stabn", s_stab
, 'n'},
401 {"stabs", s_stab
, 's'},
402 {"string", stringer
, 1},
403 {"struct", s_struct
, 0},
407 /* This is for gcc to use. It's only just been added (2/94), so gcc
408 won't be able to use it for a while -- probably a year or more.
409 But once this has been released, check with gcc maintainers
410 before deleting it or even changing the spelling. */
411 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
412 /* If we're folding case -- done for some targets, not necessarily
413 all -- the above string in an input file will be converted to
414 this one. Match it either way... */
415 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
417 {"title", listing_title
, 0}, /* Listing title. */
418 {"ttl", listing_title
, 0},
420 {"uleb128", s_leb128
, 0},
424 {"xdef", s_globl
, 0},
425 {"xref", s_ignore
, 0},
426 {"xstabs", s_xstab
, 's'},
428 {"zero", s_space
, 0},
429 {NULL
, NULL
, 0} /* End sentinel. */
432 static int pop_override_ok
= 0;
433 static const char *pop_table_name
;
437 const pseudo_typeS
*table
;
440 const pseudo_typeS
*pop
;
441 for (pop
= table
; pop
->poc_name
; pop
++)
443 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
444 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
445 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
450 #ifndef md_pop_insert
451 #define md_pop_insert() pop_insert(md_pseudo_table)
454 #ifndef obj_pop_insert
455 #define obj_pop_insert() pop_insert(obj_pseudo_table)
461 po_hash
= hash_new ();
463 /* Do the target-specific pseudo ops. */
464 pop_table_name
= "md";
467 /* Now object specific. Skip any that were in the target table. */
468 pop_table_name
= "obj";
472 /* Now portable ones. Skip any that we've seen already. */
473 pop_table_name
= "standard";
474 pop_insert (potable
);
477 #define HANDLE_CONDITIONAL_ASSEMBLY() \
478 if (ignore_input ()) \
480 while (!is_end_of_line[(unsigned char) *input_line_pointer++]) \
481 if (input_line_pointer == buffer_limit) \
486 /* This function is used when scrubbing the characters between #APP
489 static char *scrub_string
;
490 static char *scrub_string_end
;
493 scrub_from_string (buf
, buflen
)
499 copy
= scrub_string_end
- scrub_string
;
502 memcpy (buf
, scrub_string
, copy
);
503 scrub_string
+= copy
;
507 /* We read the file, putting things into a web that represents what we
508 have been reading. */
510 read_a_source_file (name
)
514 register char *s
; /* String of symbol, '\0' appended. */
522 buffer
= input_scrub_new_file (name
);
525 listing_newline (NULL
);
526 register_dependency (name
);
528 /* Generate debugging information before we've read anything in to denote
529 this file as the "main" source file and not a subordinate one
530 (e.g. N_SO vs N_SOL in stabs). */
531 generate_file_debug ();
533 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
534 { /* We have another line to parse. */
535 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
536 contin
: /* JF this goto is my fault I admit it.
537 Someone brave please re-write the whole
538 input section here? Pleeze??? */
539 while (input_line_pointer
< buffer_limit
)
541 /* We have more of this buffer to parse. */
543 /* We now have input_line_pointer->1st char of next line.
544 If input_line_pointer [-1] == '\n' then we just
545 scanned another line: so bump line counters. */
546 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
548 #ifdef md_start_line_hook
549 md_start_line_hook ();
551 if (input_line_pointer
[-1] == '\n')
552 bump_line_counters ();
556 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
558 /* Text at the start of a line must be a label, we
559 run down and stick a colon in. */
560 if (is_name_beginner (*input_line_pointer
))
562 char *line_start
= input_line_pointer
;
567 HANDLE_CONDITIONAL_ASSEMBLY ();
569 c
= get_symbol_end ();
571 /* In MRI mode, the EQU and MACRO pseudoops must
572 be handled specially. */
576 char *rest
= input_line_pointer
+ 1;
580 if (*rest
== ' ' || *rest
== '\t')
582 if ((strncasecmp (rest
, "EQU", 3) == 0
583 || strncasecmp (rest
, "SET", 3) == 0)
584 && (rest
[3] == ' ' || rest
[3] == '\t'))
586 input_line_pointer
= rest
+ 3;
588 strncasecmp (rest
, "SET", 3) == 0);
591 if (strncasecmp (rest
, "MACRO", 5) == 0
594 || is_end_of_line
[(unsigned char) rest
[5]]))
598 /* In MRI mode, we need to handle the MACRO
599 pseudo-op specially: we don't want to put the
600 symbol in the symbol table. */
602 #ifdef TC_START_LABEL_WITHOUT_COLON
603 && TC_START_LABEL_WITHOUT_COLON(c
,
607 line_label
= colon (line_start
);
609 line_label
= symbol_create (line_start
,
614 *input_line_pointer
= c
;
616 input_line_pointer
++;
621 /* We are at the begining of a line, or similar place.
622 We expect a well-formed assembler statement.
623 A "symbol-name:" is a statement.
625 Depending on what compiler is used, the order of these tests
626 may vary to catch most common case 1st.
627 Each test is independent of all other tests at the (top) level.
628 PLEASE make a compiler that doesn't use this assembler.
629 It is crufty to waste a compiler's time encoding things for this
630 assembler, which then wastes more time decoding it.
631 (And communicating via (linear) files is silly!
632 If you must pass stuff, please pass a tree!) */
633 if ((c
= *input_line_pointer
++) == '\t'
637 c
= *input_line_pointer
++;
639 know (c
!= ' '); /* No further leading whitespace. */
642 /* If listing is on, and we are expanding a macro, then give
643 the listing code the contents of the expanded line. */
646 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
651 /* Find the end of the current expanded macro line. */
652 for (s
= input_line_pointer
- 1; *s
; ++s
)
653 if (is_end_of_line
[(unsigned char) *s
])
656 /* Copy it for safe keeping. Also give an indication of
657 how much macro nesting is involved at this point. */
658 len
= s
- (input_line_pointer
- 1);
659 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
660 memset (copy
, '>', macro_nest
);
661 copy
[macro_nest
] = ' ';
662 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
- 1, len
);
663 copy
[macro_nest
+ 1 + len
] = '\0';
665 /* Install the line with the listing facility. */
666 listing_newline (copy
);
669 listing_newline (NULL
);
672 /* C is the 1st significant character.
673 Input_line_pointer points after that character. */
674 if (is_name_beginner (c
))
676 /* Want user-defined label or pseudo/opcode. */
677 HANDLE_CONDITIONAL_ASSEMBLY ();
679 s
= --input_line_pointer
;
680 c
= get_symbol_end (); /* name's delimiter. */
682 /* C is character after symbol.
683 That character's place in the input line is now '\0'.
684 S points to the beginning of the symbol.
685 [In case of pseudo-op, s->'.'.]
686 Input_line_pointer->'\0' where c was. */
687 if (TC_START_LABEL (c
, input_line_pointer
))
691 char *rest
= input_line_pointer
+ 1;
693 /* In MRI mode, \tsym: set 0 is permitted. */
697 if (*rest
== ' ' || *rest
== '\t')
700 if ((strncasecmp (rest
, "EQU", 3) == 0
701 || strncasecmp (rest
, "SET", 3) == 0)
702 && (rest
[3] == ' ' || rest
[3] == '\t'))
704 input_line_pointer
= rest
+ 3;
710 line_label
= colon (s
); /* User-defined label. */
711 /* Put ':' back for error messages' sake. */
712 *input_line_pointer
++ = ':';
713 /* Input_line_pointer->after ':'. */
717 || ((c
== ' ' || c
== '\t')
718 && input_line_pointer
[1] == '='
719 #ifdef TC_EQUAL_IN_INSN
720 && !TC_EQUAL_IN_INSN (c
, input_line_pointer
)
725 demand_empty_rest_of_line ();
729 /* Expect pseudo-op or machine instruction. */
732 #ifdef IGNORE_OPCODE_CASE
736 strncpy (original_case_string
, s2
, sizeof (original_case_string
));
737 original_case_string
[sizeof (original_case_string
) - 1] = 0;
746 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
748 /* The MRI assembler and the m88k use pseudo-ops
750 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
751 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
756 || (!flag_m68k_mri
&& *s
== '.'))
760 WARNING: c has next char, which may be end-of-line.
761 We lookup the pseudo-op table with s+1 because we
762 already know that the pseudo-op begins with a '.'. */
765 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
767 /* In MRI mode, we may need to insert an
768 automatic alignment directive. What a hack
770 if (mri_pending_align
772 || !((pop
->poc_handler
== cons
773 && pop
->poc_val
== 1)
774 || (pop
->poc_handler
== s_space
775 && pop
->poc_val
== 1)
776 #ifdef tc_conditional_pseudoop
777 || tc_conditional_pseudoop (pop
)
779 || pop
->poc_handler
== s_if
780 || pop
->poc_handler
== s_ifdef
781 || pop
->poc_handler
== s_ifc
782 || pop
->poc_handler
== s_ifeqs
783 || pop
->poc_handler
== s_else
784 || pop
->poc_handler
== s_endif
785 || pop
->poc_handler
== s_globl
786 || pop
->poc_handler
== s_ignore
)))
788 do_align (1, (char *) NULL
, 0, 0);
789 mri_pending_align
= 0;
791 if (line_label
!= NULL
)
793 symbol_set_frag (line_label
, frag_now
);
794 S_SET_VALUE (line_label
, frag_now_fix ());
798 /* Print the error msg now, while we still can. */
801 as_bad (_("unknown pseudo-op: `%s'"), s
);
802 *input_line_pointer
= c
;
807 /* Put it back for error messages etc. */
808 *input_line_pointer
= c
;
809 /* The following skip of whitespace is compulsory.
810 A well shaped space is sometimes all that separates
811 keyword from operands. */
812 if (c
== ' ' || c
== '\t')
813 input_line_pointer
++;
815 /* Input_line is restored.
816 Input_line_pointer->1st non-blank char
817 after pseudo-operation. */
818 (*pop
->poc_handler
) (pop
->poc_val
);
820 /* If that was .end, just get out now. */
821 if (pop
->poc_handler
== s_end
)
827 #ifdef QUOTES_IN_INSN
831 /* WARNING: c has char, which may be end-of-line. */
832 /* Also: input_line_pointer->`\0` where c was. */
833 *input_line_pointer
= c
;
834 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
836 #ifdef TC_EOL_IN_INSN
837 || TC_EOL_IN_INSN (input_line_pointer
)
841 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
843 #ifdef QUOTES_IN_INSN
846 else if (*input_line_pointer
== '"')
848 else if (*input_line_pointer
== '\\')
851 input_line_pointer
++;
854 c
= *input_line_pointer
;
855 *input_line_pointer
= '\0';
857 generate_lineno_debug ();
865 if (check_macro (s
, &out
, '\0', &err
, ¯o
))
869 *input_line_pointer
++ = c
;
870 input_scrub_include_sb (&out
,
871 input_line_pointer
, 1);
874 input_scrub_next_buffer (&input_line_pointer
);
876 md_macro_info (macro
);
882 if (mri_pending_align
)
884 do_align (1, (char *) NULL
, 0, 0);
885 mri_pending_align
= 0;
886 if (line_label
!= NULL
)
888 symbol_set_frag (line_label
, frag_now
);
889 S_SET_VALUE (line_label
, frag_now_fix ());
893 md_assemble (s
); /* Assemble 1 instruction. */
895 *input_line_pointer
++ = c
;
897 /* We resume loop AFTER the end-of-line from
904 /* Empty statement? */
905 if (is_end_of_line
[(unsigned char) c
])
908 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
) && ISDIGIT (c
))
910 /* local label ("4:") */
911 char *backup
= input_line_pointer
;
913 HANDLE_CONDITIONAL_ASSEMBLY ();
917 /* Read the whole number. */
918 while (ISDIGIT (*input_line_pointer
))
920 temp
= (temp
* 10) + *input_line_pointer
- '0';
921 ++input_line_pointer
;
924 if (LOCAL_LABELS_DOLLAR
925 && *input_line_pointer
== '$'
926 && *(input_line_pointer
+ 1) == ':')
928 input_line_pointer
+= 2;
930 if (dollar_label_defined (temp
))
932 as_fatal (_("label \"%d$\" redefined"), temp
);
935 define_dollar_label (temp
);
936 colon (dollar_label_name (temp
, 0));
941 && *input_line_pointer
++ == ':')
943 fb_label_instance_inc (temp
);
944 colon (fb_label_name (temp
, 0));
948 input_line_pointer
= backup
;
949 } /* local label ("4:") */
951 if (c
&& strchr (line_comment_chars
, c
))
952 { /* Its a comment. Better say APP or NO_APP. */
956 unsigned int new_length
;
959 bump_line_counters ();
960 s
= input_line_pointer
;
961 if (strncmp (s
, "APP\n", 4))
962 continue; /* We ignore it */
965 ends
= strstr (s
, "#NO_APP\n");
969 unsigned int tmp_len
;
972 /* The end of the #APP wasn't in this buffer. We
973 keep reading in buffers until we find the #NO_APP
974 that goes with this #APP There is one. The specs
976 tmp_len
= buffer_limit
- s
;
977 tmp_buf
= xmalloc (tmp_len
+ 1);
978 memcpy (tmp_buf
, s
, tmp_len
);
981 new_tmp
= input_scrub_next_buffer (&buffer
);
985 buffer_limit
= new_tmp
;
986 input_line_pointer
= buffer
;
987 ends
= strstr (buffer
, "#NO_APP\n");
991 num
= buffer_limit
- buffer
;
993 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
994 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
999 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1007 input_line_pointer
= ends
+ 8;
1011 scrub_string_end
= ends
;
1013 new_length
= ends
- s
;
1014 new_buf
= (char *) xmalloc (new_length
);
1021 space
= (new_buf
+ new_length
) - new_tmp
;
1022 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1030 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1031 new_tmp
= new_buf
+ new_length
;
1037 old_buffer
= buffer
;
1038 old_input
= input_line_pointer
;
1039 old_limit
= buffer_limit
;
1041 input_line_pointer
= new_buf
;
1042 buffer_limit
= new_tmp
;
1047 HANDLE_CONDITIONAL_ASSEMBLY ();
1049 #ifdef tc_unrecognized_line
1050 if (tc_unrecognized_line (c
))
1053 input_line_pointer
--;
1054 /* Report unknown char as ignored. */
1055 ignore_rest_of_line ();
1058 #ifdef md_after_pass_hook
1059 md_after_pass_hook ();
1065 bump_line_counters ();
1068 buffer
= old_buffer
;
1069 input_line_pointer
= old_input
;
1070 buffer_limit
= old_limit
;
1082 /* Close the input file. */
1083 input_scrub_close ();
1084 #ifdef WARN_COMMENTS
1086 if (warn_comment
&& found_comment
)
1087 as_warn_where (found_comment_file
, found_comment
,
1088 "first comment found here");
1093 /* For most MRI pseudo-ops, the line actually ends at the first
1094 nonquoted space. This function looks for that point, stuffs a null
1095 in, and sets *STOPCP to the character that used to be there, and
1096 returns the location.
1098 Until I hear otherwise, I am going to assume that this is only true
1099 for the m68k MRI assembler. */
1102 mri_comment_field (stopcp
)
1109 know (flag_m68k_mri
);
1111 for (s
= input_line_pointer
;
1112 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1120 for (s
= input_line_pointer
;
1121 !is_end_of_line
[(unsigned char) *s
];
1131 /* Skip to the end of an MRI comment field. */
1134 mri_comment_end (stop
, stopc
)
1140 input_line_pointer
= stop
;
1142 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1143 ++input_line_pointer
;
1148 int ignore ATTRIBUTE_UNUSED
;
1150 as_fatal (_(".abort detected. Abandoning ship."));
1153 /* Guts of .align directive. N is the power of two to which to align.
1154 FILL may be NULL, or it may point to the bytes of the fill pattern.
1155 LEN is the length of whatever FILL points to, if anything. MAX is
1156 the maximum number of characters to skip when doing the alignment,
1157 or 0 if there is no maximum. */
1160 do_align (n
, fill
, len
, max
)
1166 if (now_seg
== absolute_section
)
1170 if (*fill
++ != '\0')
1172 as_warn (_("ignoring fill value in absolute section"));
1180 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1183 /* Only make a frag if we HAVE to... */
1184 if (n
!= 0 && !need_pass_2
)
1188 if (subseg_text_p (now_seg
))
1189 frag_align_code (n
, max
);
1191 frag_align (n
, 0, max
);
1194 frag_align (n
, *fill
, max
);
1196 frag_align_pattern (n
, fill
, len
, max
);
1200 just_record_alignment
:
1203 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1206 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1207 (in bytes). A negative ARG is the negative of the length of the
1208 fill pattern. BYTES_P is non-zero if the alignment value should be
1209 interpreted as the byte boundary, rather than the power of 2. */
1212 s_align (arg
, bytes_p
)
1216 register unsigned int align
;
1224 stop
= mri_comment_field (&stopc
);
1226 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1231 align
= arg
; /* Default value from pseudo-op table. */
1235 align
= get_absolute_expression ();
1241 /* Convert to a power of 2. */
1246 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1249 as_bad (_("alignment not a power of 2"));
1258 as_warn (_("alignment too large: %u assumed"), align
);
1261 if (*input_line_pointer
!= ',')
1268 ++input_line_pointer
;
1269 if (*input_line_pointer
== ',')
1273 fill
= get_absolute_expression ();
1278 if (*input_line_pointer
!= ',')
1282 ++input_line_pointer
;
1283 max
= get_absolute_expression ();
1290 as_warn (_("expected fill pattern missing"));
1291 do_align (align
, (char *) NULL
, 0, max
);
1306 do_align (align
, &fill_char
, fill_len
, max
);
1312 if ((size_t) fill_len
> sizeof ab
)
1314 md_number_to_chars (ab
, fill
, fill_len
);
1315 do_align (align
, ab
, fill_len
, max
);
1319 demand_empty_rest_of_line ();
1322 mri_comment_end (stop
, stopc
);
1325 /* Handle the .align pseudo-op on machines where ".align 4" means
1326 align to a 4 byte boundary. */
1335 /* Handle the .align pseudo-op on machines where ".align 4" means align
1336 to a 2**4 boundary. */
1347 int ignore ATTRIBUTE_UNUSED
;
1349 register char *name
;
1353 register symbolS
*symbolP
;
1358 stop
= mri_comment_field (&stopc
);
1360 name
= input_line_pointer
;
1361 c
= get_symbol_end ();
1362 /* Just after name is now '\0'. */
1363 p
= input_line_pointer
;
1368 as_bad (_("expected symbol name"));
1369 discard_rest_of_line ();
1375 if (*input_line_pointer
!= ',')
1378 as_bad (_("expected comma after \"%s\""), name
);
1380 ignore_rest_of_line ();
1382 mri_comment_end (stop
, stopc
);
1386 input_line_pointer
++; /* skip ',' */
1388 if ((temp
= get_absolute_expression ()) < 0)
1390 as_warn (_(".COMMon length (%ld) < 0 ignored"), (long) temp
);
1391 ignore_rest_of_line ();
1393 mri_comment_end (stop
, stopc
);
1398 symbolP
= symbol_find_or_make (name
);
1401 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1403 as_bad (_("symbol `%s' is already defined"),
1404 S_GET_NAME (symbolP
));
1405 ignore_rest_of_line ();
1407 mri_comment_end (stop
, stopc
);
1411 if (S_GET_VALUE (symbolP
))
1413 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1414 as_bad (_("length of .comm \"%s\" is already %ld; not changing to %ld"),
1415 S_GET_NAME (symbolP
),
1416 (long) S_GET_VALUE (symbolP
),
1421 S_SET_VALUE (symbolP
, (valueT
) temp
);
1422 S_SET_EXTERNAL (symbolP
);
1426 extern int flag_one
;
1427 if (!temp
|| !flag_one
)
1428 S_GET_OTHER(symbolP
) = const_flag
;
1430 #endif /* not OBJ_VMS */
1431 know (symbolP
->sy_frag
== &zero_address_frag
);
1433 demand_empty_rest_of_line ();
1436 mri_comment_end (stop
, stopc
);
1439 /* The MRI COMMON pseudo-op. We handle this by creating a common
1440 symbol with the appropriate name. We make s_space do the right
1441 thing by increasing the size. */
1444 s_mri_common (small
)
1445 int small ATTRIBUTE_UNUSED
;
1461 stop
= mri_comment_field (&stopc
);
1465 name
= input_line_pointer
;
1466 if (!ISDIGIT (*name
))
1467 c
= get_symbol_end ();
1472 ++input_line_pointer
;
1474 while (ISDIGIT (*input_line_pointer
));
1476 c
= *input_line_pointer
;
1477 *input_line_pointer
= '\0';
1479 if (line_label
!= NULL
)
1481 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1482 + (input_line_pointer
- name
)
1484 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1489 sym
= symbol_find_or_make (name
);
1490 *input_line_pointer
= c
;
1494 if (*input_line_pointer
!= ',')
1498 ++input_line_pointer
;
1499 align
= get_absolute_expression ();
1502 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1504 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1505 ignore_rest_of_line ();
1506 mri_comment_end (stop
, stopc
);
1510 S_SET_EXTERNAL (sym
);
1511 mri_common_symbol
= sym
;
1515 S_SET_ALIGN (sym
, align
);
1518 if (line_label
!= NULL
)
1521 exp
.X_op
= O_symbol
;
1522 exp
.X_add_symbol
= sym
;
1523 exp
.X_add_number
= 0;
1524 symbol_set_value_expression (line_label
, &exp
);
1525 symbol_set_frag (line_label
, &zero_address_frag
);
1526 S_SET_SEGMENT (line_label
, expr_section
);
1529 /* FIXME: We just ignore the small argument, which distinguishes
1530 COMMON and COMMON.S. I don't know what we can do about it. */
1532 /* Ignore the type and hptype. */
1533 if (*input_line_pointer
== ',')
1534 input_line_pointer
+= 2;
1535 if (*input_line_pointer
== ',')
1536 input_line_pointer
+= 2;
1538 demand_empty_rest_of_line ();
1540 mri_comment_end (stop
, stopc
);
1545 int ignore ATTRIBUTE_UNUSED
;
1550 temp
= get_absolute_expression ();
1551 if (flag_readonly_data_in_text
)
1553 section
= text_section
;
1557 section
= data_section
;
1559 subseg_set (section
, (subsegT
) temp
);
1564 demand_empty_rest_of_line ();
1567 /* Handle the .appfile pseudo-op. This is automatically generated by
1568 do_scrub_chars when a preprocessor # line comment is seen with a
1569 file name. This default definition may be overridden by the object
1570 or CPU specific pseudo-ops. This function is also the default
1571 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1575 s_app_file_string (file
)
1580 listing_source_file (file
);
1582 register_dependency (file
);
1584 obj_app_file (file
);
1589 s_app_file (appfile
)
1595 /* Some assemblers tolerate immediately following '"'. */
1596 if ((s
= demand_copy_string (&length
)) != 0)
1598 /* If this is a fake .appfile, a fake newline was inserted into
1599 the buffer. Passing -2 to new_logical_line tells it to
1602 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1604 /* In MRI mode, the preprocessor may have inserted an extraneous
1607 && *input_line_pointer
== '\''
1608 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1609 ++input_line_pointer
;
1611 demand_empty_rest_of_line ();
1613 s_app_file_string (s
);
1617 /* Handle the .appline pseudo-op. This is automatically generated by
1618 do_scrub_chars when a preprocessor # line comment is seen. This
1619 default definition may be overridden by the object or CPU specific
1624 int ignore ATTRIBUTE_UNUSED
;
1628 /* The given number is that of the next line. */
1629 l
= get_absolute_expression () - 1;
1631 /* Some of the back ends can't deal with non-positive line numbers.
1632 Besides, it's silly. */
1633 as_warn (_("line numbers must be positive; line number %d rejected"),
1637 new_logical_line ((char *) NULL
, l
);
1640 listing_source_line (l
);
1643 demand_empty_rest_of_line ();
1646 /* Handle the .end pseudo-op. Actually, the real work is done in
1647 read_a_source_file. */
1651 int ignore ATTRIBUTE_UNUSED
;
1655 /* The MRI assembler permits the start symbol to follow .end,
1656 but we don't support that. */
1658 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1659 && *input_line_pointer
!= '*'
1660 && *input_line_pointer
!= '!')
1661 as_warn (_("start address not supported"));
1665 /* Handle the .err pseudo-op. */
1669 int ignore ATTRIBUTE_UNUSED
;
1671 as_bad (_(".err encountered"));
1672 demand_empty_rest_of_line ();
1675 /* Handle the MRI fail pseudo-op. */
1679 int ignore ATTRIBUTE_UNUSED
;
1686 stop
= mri_comment_field (&stopc
);
1688 temp
= get_absolute_expression ();
1690 as_warn (_(".fail %ld encountered"), (long) temp
);
1692 as_bad (_(".fail %ld encountered"), (long) temp
);
1694 demand_empty_rest_of_line ();
1697 mri_comment_end (stop
, stopc
);
1702 int ignore ATTRIBUTE_UNUSED
;
1704 expressionS rep_exp
;
1706 register long fill
= 0;
1709 #ifdef md_flush_pending_output
1710 md_flush_pending_output ();
1713 get_known_segmented_expression (&rep_exp
);
1714 if (*input_line_pointer
== ',')
1716 input_line_pointer
++;
1717 size
= get_absolute_expression ();
1718 if (*input_line_pointer
== ',')
1720 input_line_pointer
++;
1721 fill
= get_absolute_expression ();
1725 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1726 #define BSD_FILL_SIZE_CROCK_8 (8)
1727 if (size
> BSD_FILL_SIZE_CROCK_8
)
1729 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
1730 size
= BSD_FILL_SIZE_CROCK_8
;
1734 as_warn (_("size negative; .fill ignored"));
1737 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1739 if (rep_exp
.X_add_number
< 0)
1740 as_warn (_("repeat < 0; .fill ignored"));
1744 if (size
&& !need_pass_2
)
1746 if (rep_exp
.X_op
== O_constant
)
1748 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1749 (relax_substateT
) 0, (symbolS
*) 0,
1750 (offsetT
) rep_exp
.X_add_number
,
1755 /* We don't have a constant repeat count, so we can't use
1756 rs_fill. We can get the same results out of rs_space,
1757 but its argument is in bytes, so we must multiply the
1758 repeat count by size. */
1761 rep_sym
= make_expr_symbol (&rep_exp
);
1764 expressionS size_exp
;
1765 size_exp
.X_op
= O_constant
;
1766 size_exp
.X_add_number
= size
;
1768 rep_exp
.X_op
= O_multiply
;
1769 rep_exp
.X_add_symbol
= rep_sym
;
1770 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1771 rep_exp
.X_add_number
= 0;
1772 rep_sym
= make_expr_symbol (&rep_exp
);
1775 p
= frag_var (rs_space
, (int) size
, (int) size
,
1776 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1779 memset (p
, 0, (unsigned int) size
);
1781 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1782 flavoured AS. The following bizarre behaviour is to be
1783 compatible with above. I guess they tried to take up to 8
1784 bytes from a 4-byte expression and they forgot to sign
1786 #define BSD_FILL_SIZE_CROCK_4 (4)
1787 md_number_to_chars (p
, (valueT
) fill
,
1788 (size
> BSD_FILL_SIZE_CROCK_4
1789 ? BSD_FILL_SIZE_CROCK_4
1791 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1792 but emits no error message because it seems a legal thing to do.
1793 It is a degenerate case of .fill but could be emitted by a
1796 demand_empty_rest_of_line ();
1801 int ignore ATTRIBUTE_UNUSED
;
1810 stop
= mri_comment_field (&stopc
);
1814 name
= input_line_pointer
;
1815 c
= get_symbol_end ();
1816 symbolP
= symbol_find_or_make (name
);
1817 S_SET_EXTERNAL (symbolP
);
1819 *input_line_pointer
= c
;
1821 c
= *input_line_pointer
;
1824 input_line_pointer
++;
1826 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1832 demand_empty_rest_of_line ();
1835 mri_comment_end (stop
, stopc
);
1838 /* Handle the MRI IRP and IRPC pseudo-ops. */
1850 as_where (&file
, &line
);
1853 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1854 sb_add_char (&s
, *input_line_pointer
++);
1858 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1860 as_bad_where (file
, line
, "%s", err
);
1864 input_scrub_include_sb (&out
, input_line_pointer
, 1);
1866 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1869 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1870 the section to only be linked once. However, this is not supported
1871 by most object file formats. This takes an optional argument,
1872 which is what to do about duplicates. */
1876 int ignore ATTRIBUTE_UNUSED
;
1878 enum linkonce_type type
;
1882 type
= LINKONCE_DISCARD
;
1884 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1889 s
= input_line_pointer
;
1890 c
= get_symbol_end ();
1891 if (strcasecmp (s
, "discard") == 0)
1892 type
= LINKONCE_DISCARD
;
1893 else if (strcasecmp (s
, "one_only") == 0)
1894 type
= LINKONCE_ONE_ONLY
;
1895 else if (strcasecmp (s
, "same_size") == 0)
1896 type
= LINKONCE_SAME_SIZE
;
1897 else if (strcasecmp (s
, "same_contents") == 0)
1898 type
= LINKONCE_SAME_CONTENTS
;
1900 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1902 *input_line_pointer
= c
;
1905 #ifdef obj_handle_link_once
1906 obj_handle_link_once (type
);
1907 #else /* ! defined (obj_handle_link_once) */
1908 #ifdef BFD_ASSEMBLER
1912 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1913 as_warn (_(".linkonce is not supported for this object file format"));
1915 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1916 flags
|= SEC_LINK_ONCE
;
1921 case LINKONCE_DISCARD
:
1922 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1924 case LINKONCE_ONE_ONLY
:
1925 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1927 case LINKONCE_SAME_SIZE
:
1928 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1930 case LINKONCE_SAME_CONTENTS
:
1931 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1934 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1935 as_bad (_("bfd_set_section_flags: %s"),
1936 bfd_errmsg (bfd_get_error ()));
1938 #else /* ! defined (BFD_ASSEMBLER) */
1939 as_warn (_(".linkonce is not supported for this object file format"));
1940 #endif /* ! defined (BFD_ASSEMBLER) */
1941 #endif /* ! defined (obj_handle_link_once) */
1943 demand_empty_rest_of_line ();
1947 s_lcomm_internal (needs_align
, bytes_p
)
1948 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1949 (alignment); 0 if it was an ".lcomm" (2 args only). */
1951 /* 1 if the alignment value should be interpreted as the byte boundary,
1952 rather than the power of 2. */
1955 register char *name
;
1959 register symbolS
*symbolP
;
1960 segT current_seg
= now_seg
;
1961 subsegT current_subseg
= now_subseg
;
1962 const int max_alignment
= 15;
1964 segT bss_seg
= bss_section
;
1966 name
= input_line_pointer
;
1967 c
= get_symbol_end ();
1968 p
= input_line_pointer
;
1973 as_bad (_("expected symbol name"));
1974 discard_rest_of_line ();
1980 /* Accept an optional comma after the name. The comma used to be
1981 required, but Irix 5 cc does not generate it. */
1982 if (*input_line_pointer
== ',')
1984 ++input_line_pointer
;
1988 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1990 as_bad (_("missing size expression"));
1994 if ((temp
= get_absolute_expression ()) < 0)
1996 as_warn (_("BSS length (%d) < 0 ignored"), temp
);
1997 ignore_rest_of_line ();
2001 #if defined (TC_MIPS) || defined (TC_ALPHA)
2002 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
2003 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
2005 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
2006 if ((unsigned) temp
<= bfd_get_gp_size (stdoutput
))
2008 bss_seg
= subseg_new (".sbss", 1);
2009 seg_info (bss_seg
)->bss
= 1;
2010 #ifdef BFD_ASSEMBLER
2011 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
2012 as_warn (_("error setting flags for \".sbss\": %s"),
2013 bfd_errmsg (bfd_get_error ()));
2021 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
2023 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
2025 record_alignment (bss_seg
, align
);
2033 if (*input_line_pointer
!= ',')
2035 as_bad (_("expected comma after size"));
2036 ignore_rest_of_line ();
2040 input_line_pointer
++;
2043 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2045 as_bad (_("missing alignment"));
2049 align
= get_absolute_expression ();
2053 /* Convert to a power of 2. */
2058 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2061 as_bad (_("alignment not a power of 2"));
2066 if (align
> max_alignment
)
2068 align
= max_alignment
;
2069 as_warn (_("alignment too large; %d assumed"), align
);
2074 as_warn (_("alignment negative; 0 assumed"));
2077 record_alignment (bss_seg
, align
);
2081 /* Assume some objects may require alignment on some systems. */
2082 #if defined (TC_ALPHA) && ! defined (VMS)
2085 align
= ffs (temp
) - 1;
2086 if (temp
% (1 << align
))
2093 symbolP
= symbol_find_or_make (name
);
2097 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2098 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2099 #ifdef BFD_ASSEMBLER
2100 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2101 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2103 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2106 (S_GET_SEGMENT (symbolP
) == bss_seg
2107 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2111 subseg_set (bss_seg
, 1);
2114 frag_align (align
, 0, 0);
2116 /* Detach from old frag. */
2117 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2118 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2120 symbol_set_frag (symbolP
, frag_now
);
2121 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2122 (offsetT
) temp
, (char *) 0);
2125 S_SET_SEGMENT (symbolP
, bss_seg
);
2128 /* The symbol may already have been created with a preceding
2129 ".globl" directive -- be careful not to step on storage class
2130 in that case. Otherwise, set it to static. */
2131 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2133 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2135 #endif /* OBJ_COFF */
2138 S_SET_SIZE (symbolP
, temp
);
2142 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2144 subseg_set (current_seg
, current_subseg
);
2146 demand_empty_rest_of_line ();
2150 s_lcomm (needs_align
)
2153 s_lcomm_internal (needs_align
, 0);
2157 s_lcomm_bytes (needs_align
)
2160 s_lcomm_internal (needs_align
, 1);
2165 int ignore ATTRIBUTE_UNUSED
;
2167 register char *name
;
2171 register symbolS
*symbolP
;
2173 /* We permit ANY defined expression: BSD4.2 demands constants. */
2174 name
= input_line_pointer
;
2175 c
= get_symbol_end ();
2176 p
= input_line_pointer
;
2181 as_bad (_("expected symbol name"));
2182 discard_rest_of_line ();
2188 if (*input_line_pointer
!= ',')
2191 as_bad (_("expected comma after \"%s\""), name
);
2193 ignore_rest_of_line ();
2197 input_line_pointer
++;
2200 if (exp
.X_op
!= O_constant
2201 && exp
.X_op
!= O_register
)
2203 as_bad (_("bad expression"));
2204 ignore_rest_of_line ();
2209 symbolP
= symbol_find_or_make (name
);
2211 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2212 symbolP->sy_desc == 0) out of this test because coff doesn't have
2213 those fields, and I can't see when they'd ever be tripped. I
2214 don't think I understand why they were here so I may have
2215 introduced a bug. As recently as 1.37 didn't have this test
2216 anyway. xoxorich. */
2218 if (S_GET_SEGMENT (symbolP
) == undefined_section
2219 && S_GET_VALUE (symbolP
) == 0)
2221 /* The name might be an undefined .global symbol; be sure to
2222 keep the "external" bit. */
2223 S_SET_SEGMENT (symbolP
,
2224 (exp
.X_op
== O_constant
2227 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2231 as_bad (_("symbol `%s' is already defined"), name
);
2235 demand_empty_rest_of_line ();
2238 /* Read a line into an sb. */
2244 char quote1
, quote2
, inquote
;
2246 if (input_line_pointer
[-1] == '\n')
2247 bump_line_counters ();
2249 if (input_line_pointer
>= buffer_limit
)
2251 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2252 if (buffer_limit
== 0)
2256 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2257 code needs to be changed. */
2266 #ifdef LEX_IS_STRINGQUOTE
2272 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2273 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2275 if (inquote
== *input_line_pointer
)
2277 else if (inquote
== '\0')
2279 if (*input_line_pointer
== quote1
)
2281 else if (*input_line_pointer
== quote2
)
2285 sb_add_char (line
, *input_line_pointer
++);
2288 while (input_line_pointer
< buffer_limit
2289 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2291 if (input_line_pointer
[-1] == '\n')
2292 bump_line_counters ();
2293 ++input_line_pointer
;
2299 /* Define a macro. This is an interface to macro.c, which is shared
2300 between gas and gasp. */
2304 int ignore ATTRIBUTE_UNUSED
;
2313 as_where (&file
, &line
);
2316 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2317 sb_add_char (&s
, *input_line_pointer
++);
2320 if (line_label
!= NULL
)
2321 sb_add_string (&label
, S_GET_NAME (line_label
));
2323 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2325 as_bad_where (file
, line
, "%s", err
);
2328 if (line_label
!= NULL
)
2330 S_SET_SEGMENT (line_label
, undefined_section
);
2331 S_SET_VALUE (line_label
, 0);
2332 symbol_set_frag (line_label
, &zero_address_frag
);
2335 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2336 && hash_find (po_hash
, name
) != NULL
)
2339 && hash_find (po_hash
, name
+ 1) != NULL
))
2340 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2347 /* Handle the .mexit pseudo-op, which immediately exits a macro
2352 int ignore ATTRIBUTE_UNUSED
;
2354 cond_exit_macro (macro_nest
);
2355 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2358 /* Switch in and out of MRI mode. */
2362 int ignore ATTRIBUTE_UNUSED
;
2366 on
= get_absolute_expression ();
2367 old_flag
= flag_mri
;
2385 /* Operator precedence changes in m68k MRI mode, so we need to
2386 update the operator rankings. */
2387 expr_set_precedence ();
2389 #ifdef MRI_MODE_CHANGE
2391 MRI_MODE_CHANGE (on
);
2394 demand_empty_rest_of_line ();
2397 /* Handle changing the location counter. */
2400 do_org (segment
, exp
, fill
)
2405 if (segment
!= now_seg
&& segment
!= absolute_section
)
2406 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2408 if (now_seg
== absolute_section
)
2411 as_warn (_("ignoring fill value in absolute section"));
2412 if (exp
->X_op
!= O_constant
)
2414 as_bad (_("only constant offsets supported in absolute section"));
2415 exp
->X_add_number
= 0;
2417 abs_section_offset
= exp
->X_add_number
;
2422 symbolS
*sym
= exp
->X_add_symbol
;
2423 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2425 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2427 /* Handle complex expressions. */
2428 sym
= make_expr_symbol (exp
);
2432 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2439 int ignore ATTRIBUTE_UNUSED
;
2441 register segT segment
;
2443 register long temp_fill
;
2445 #ifdef md_flush_pending_output
2446 md_flush_pending_output ();
2449 /* The m68k MRI assembler has a different meaning for .org. It
2450 means to create an absolute section at a given address. We can't
2451 support that--use a linker script instead. */
2454 as_bad (_("MRI style ORG pseudo-op not supported"));
2455 ignore_rest_of_line ();
2459 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2460 thing as a sub-segment-relative origin. Any absolute origin is
2461 given a warning, then assumed to be segment-relative. Any
2462 segmented origin expression ("foo+42") had better be in the right
2463 segment or the .org is ignored.
2465 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2466 we never know sub-segment sizes when we are reading code. BSD
2467 will crash trying to emit negative numbers of filler bytes in
2468 certain .orgs. We don't crash, but see as-write for that code.
2470 Don't make frag if need_pass_2==1. */
2471 segment
= get_known_segmented_expression (&exp
);
2472 if (*input_line_pointer
== ',')
2474 input_line_pointer
++;
2475 temp_fill
= get_absolute_expression ();
2481 do_org (segment
, &exp
, temp_fill
);
2483 demand_empty_rest_of_line ();
2486 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2487 called by the obj-format routine which handles section changing
2488 when in MRI mode. It will create a new section, and return it. It
2489 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2490 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2491 flags will be set in the section. */
2495 char *type ATTRIBUTE_UNUSED
;
2505 name
= input_line_pointer
;
2506 if (!ISDIGIT (*name
))
2507 c
= get_symbol_end ();
2512 ++input_line_pointer
;
2514 while (ISDIGIT (*input_line_pointer
));
2516 c
= *input_line_pointer
;
2517 *input_line_pointer
= '\0';
2520 name
= xstrdup (name
);
2522 *input_line_pointer
= c
;
2524 seg
= subseg_new (name
, 0);
2526 if (*input_line_pointer
== ',')
2530 ++input_line_pointer
;
2531 align
= get_absolute_expression ();
2532 record_alignment (seg
, align
);
2536 if (*input_line_pointer
== ',')
2538 c
= *++input_line_pointer
;
2540 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2543 as_bad (_("unrecognized section type"));
2544 ++input_line_pointer
;
2546 #ifdef BFD_ASSEMBLER
2550 flags
= SEC_NO_FLAGS
;
2552 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2553 else if (*type
== 'D' || *type
== 'M')
2554 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2555 else if (*type
== 'R')
2556 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2557 if (flags
!= SEC_NO_FLAGS
)
2559 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2560 as_warn (_("error setting flags for \"%s\": %s"),
2561 bfd_section_name (stdoutput
, seg
),
2562 bfd_errmsg (bfd_get_error ()));
2568 /* Ignore the HP type. */
2569 if (*input_line_pointer
== ',')
2570 input_line_pointer
+= 2;
2572 demand_empty_rest_of_line ();
2574 #else /* ! TC_M68K */
2583 name
= input_line_pointer
;
2584 c
= get_symbol_end ();
2586 name
= xstrdup (name
);
2588 *input_line_pointer
= c
;
2590 seg
= subseg_new (name
, 0);
2592 if (*input_line_pointer
!= ',')
2598 ++input_line_pointer
;
2600 sectype
= input_line_pointer
;
2601 c
= get_symbol_end ();
2602 if (*sectype
== '\0')
2604 else if (strcasecmp (sectype
, "text") == 0)
2606 else if (strcasecmp (sectype
, "data") == 0)
2608 else if (strcasecmp (sectype
, "romdata") == 0)
2611 as_warn (_("unrecognized section type `%s'"), sectype
);
2612 *input_line_pointer
= c
;
2615 if (*input_line_pointer
== ',')
2619 ++input_line_pointer
;
2621 seccmd
= input_line_pointer
;
2622 c
= get_symbol_end ();
2623 if (strcasecmp (seccmd
, "absolute") == 0)
2625 as_bad (_("absolute sections are not supported"));
2626 *input_line_pointer
= c
;
2627 ignore_rest_of_line ();
2630 else if (strcasecmp (seccmd
, "align") == 0)
2634 *input_line_pointer
= c
;
2635 align
= get_absolute_expression ();
2636 record_alignment (seg
, align
);
2640 as_warn (_("unrecognized section command `%s'"), seccmd
);
2641 *input_line_pointer
= c
;
2645 demand_empty_rest_of_line ();
2647 #else /* ! TC_I960 */
2648 /* The MRI assembler seems to use different forms of .sect for
2649 different targets. */
2650 as_bad ("MRI mode not supported for this target");
2651 ignore_rest_of_line ();
2652 #endif /* ! TC_I960 */
2653 #endif /* ! TC_M68K */
2656 /* Handle the .print pseudo-op. */
2660 int ignore ATTRIBUTE_UNUSED
;
2665 s
= demand_copy_C_string (&len
);
2667 demand_empty_rest_of_line ();
2670 /* Handle the .purgem pseudo-op. */
2674 int ignore ATTRIBUTE_UNUSED
;
2676 if (is_it_end_of_statement ())
2678 demand_empty_rest_of_line ();
2688 name
= input_line_pointer
;
2689 c
= get_symbol_end ();
2690 delete_macro (name
);
2691 *input_line_pointer
= c
;
2694 while (*input_line_pointer
++ == ',');
2696 --input_line_pointer
;
2697 demand_empty_rest_of_line ();
2700 /* Handle the .rept pseudo-op. */
2704 int ignore ATTRIBUTE_UNUSED
;
2706 as_warn (_(".endr encountered without preceeding .rept, .irc, or .irp"));
2707 demand_empty_rest_of_line ();
2710 /* Handle the .rept pseudo-op. */
2714 int ignore ATTRIBUTE_UNUSED
;
2718 count
= get_absolute_expression ();
2720 do_repeat (count
, "REPT", "ENDR");
2723 /* This function provides a generic repeat block implementation. It allows
2724 different directives to be used as the start/end keys. */
2727 do_repeat (count
, start
, end
)
2736 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2738 as_bad (_("%s without %s"), start
, end
);
2744 sb_add_sb (&many
, &one
);
2748 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2750 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2753 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2754 input buffers to skip. Assumes that conditionals preceding the loop end
2755 are properly nested.
2757 This function makes it easier to implement a premature "break" out of the
2758 loop. The EXTRA arg accounts for other buffers we might have inserted,
2759 such as line substitutions. */
2765 cond_exit_macro (macro_nest
);
2766 while (extra
-- >= 0)
2767 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2770 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2771 this is .equiv, and it is an error if the symbol is already
2778 register char *name
;
2779 register char delim
;
2780 register char *end_name
;
2781 register symbolS
*symbolP
;
2783 /* Especial apologies for the random logic:
2784 this just grew, and could be parsed much more simply!
2786 name
= input_line_pointer
;
2787 delim
= get_symbol_end ();
2788 end_name
= input_line_pointer
;
2791 if (name
== end_name
)
2793 as_bad (_("expected symbol name"));
2794 discard_rest_of_line ();
2800 if (*input_line_pointer
!= ',')
2803 as_bad (_("expected comma after \"%s\""), name
);
2805 ignore_rest_of_line ();
2809 input_line_pointer
++;
2812 if (name
[0] == '.' && name
[1] == '\0')
2814 /* Turn '. = mumble' into a .org mumble. */
2815 register segT segment
;
2818 segment
= get_known_segmented_expression (&exp
);
2821 do_org (segment
, &exp
, 0);
2827 if ((symbolP
= symbol_find (name
)) == NULL
2828 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2831 /* When doing symbol listings, play games with dummy fragments living
2832 outside the normal fragment chain to record the file and line info
2834 if (listing
& LISTING_SYMBOLS
)
2836 extern struct list_info_struct
*listing_tail
;
2837 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2838 memset (dummy_frag
, 0, sizeof (fragS
));
2839 dummy_frag
->fr_type
= rs_fill
;
2840 dummy_frag
->line
= listing_tail
;
2841 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2842 dummy_frag
->fr_symbol
= symbolP
;
2846 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2849 /* "set" symbols are local unless otherwise specified. */
2850 SF_SET_LOCAL (symbolP
);
2851 #endif /* OBJ_COFF */
2854 symbol_table_insert (symbolP
);
2859 && S_IS_DEFINED (symbolP
)
2860 && S_GET_SEGMENT (symbolP
) != reg_section
)
2861 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2863 pseudo_set (symbolP
);
2864 demand_empty_rest_of_line ();
2878 #ifdef md_flush_pending_output
2879 md_flush_pending_output ();
2883 stop
= mri_comment_field (&stopc
);
2885 /* In m68k MRI mode, we need to align to a word boundary, unless
2887 if (flag_m68k_mri
&& mult
> 1)
2889 if (now_seg
== absolute_section
)
2891 abs_section_offset
+= abs_section_offset
& 1;
2892 if (line_label
!= NULL
)
2893 S_SET_VALUE (line_label
, abs_section_offset
);
2895 else if (mri_common_symbol
!= NULL
)
2899 val
= S_GET_VALUE (mri_common_symbol
);
2902 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2903 if (line_label
!= NULL
)
2905 expressionS
*symexp
;
2907 symexp
= symbol_get_value_expression (line_label
);
2908 know (symexp
->X_op
== O_symbol
);
2909 know (symexp
->X_add_symbol
== mri_common_symbol
);
2910 symexp
->X_add_number
+= 1;
2916 do_align (1, (char *) NULL
, 0, 0);
2917 if (line_label
!= NULL
)
2919 symbol_set_frag (line_label
, frag_now
);
2920 S_SET_VALUE (line_label
, frag_now_fix ());
2930 if (*input_line_pointer
== ',')
2932 ++input_line_pointer
;
2937 val
.X_op
= O_constant
;
2938 val
.X_add_number
= 0;
2941 if (val
.X_op
!= O_constant
2942 || val
.X_add_number
< - 0x80
2943 || val
.X_add_number
> 0xff
2944 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2946 if (exp
.X_op
!= O_constant
)
2947 as_bad (_("unsupported variable size or fill value"));
2954 bytes
= mult
* exp
.X_add_number
;
2955 for (i
= 0; i
< exp
.X_add_number
; i
++)
2956 emit_expr (&val
, mult
);
2961 if (exp
.X_op
== O_constant
)
2965 repeat
= exp
.X_add_number
;
2972 as_warn (_(".space repeat count is zero, ignored"));
2973 else if (repeat
< 0)
2974 as_warn (_(".space repeat count is negative, ignored"));
2978 /* If we are in the absolute section, just bump the offset. */
2979 if (now_seg
== absolute_section
)
2981 abs_section_offset
+= repeat
;
2985 /* If we are secretly in an MRI common section, then
2986 creating space just increases the size of the common
2988 if (mri_common_symbol
!= NULL
)
2990 S_SET_VALUE (mri_common_symbol
,
2991 S_GET_VALUE (mri_common_symbol
) + repeat
);
2996 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2997 (offsetT
) repeat
, (char *) 0);
3001 if (now_seg
== absolute_section
)
3003 as_bad (_("space allocation too complex in absolute section"));
3004 subseg_set (text_section
, 0);
3007 if (mri_common_symbol
!= NULL
)
3009 as_bad (_("space allocation too complex in common section"));
3010 mri_common_symbol
= NULL
;
3014 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
3015 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
3019 *p
= val
.X_add_number
;
3024 /* In MRI mode, after an odd number of bytes, we must align to an
3025 even word boundary, unless the next instruction is a dc.b, ds.b
3027 if (flag_mri
&& (bytes
& 1) != 0)
3028 mri_pending_align
= 1;
3030 demand_empty_rest_of_line ();
3033 mri_comment_end (stop
, stopc
);
3036 /* This is like s_space, but the value is a floating point number with
3037 the given precision. This is for the MRI dcb.s pseudo-op and
3041 s_float_space (float_type
)
3046 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3051 stop
= mri_comment_field (&stopc
);
3053 count
= get_absolute_expression ();
3056 if (*input_line_pointer
!= ',')
3058 as_bad (_("missing value"));
3059 ignore_rest_of_line ();
3061 mri_comment_end (stop
, stopc
);
3065 ++input_line_pointer
;
3069 /* Skip any 0{letter} that may be present. Don't even check if the
3070 * letter is legal. */
3071 if (input_line_pointer
[0] == '0'
3072 && ISALPHA (input_line_pointer
[1]))
3073 input_line_pointer
+= 2;
3075 /* Accept :xxxx, where the x's are hex digits, for a floating point
3076 with the exact digits specified. */
3077 if (input_line_pointer
[0] == ':')
3079 flen
= hex_float (float_type
, temp
);
3082 ignore_rest_of_line ();
3084 mri_comment_end (stop
, stopc
);
3092 err
= md_atof (float_type
, temp
, &flen
);
3093 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3097 as_bad (_("bad floating literal: %s"), err
);
3098 ignore_rest_of_line ();
3100 mri_comment_end (stop
, stopc
);
3105 while (--count
>= 0)
3109 p
= frag_more (flen
);
3110 memcpy (p
, temp
, (unsigned int) flen
);
3113 demand_empty_rest_of_line ();
3116 mri_comment_end (stop
, stopc
);
3119 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3123 int ignore ATTRIBUTE_UNUSED
;
3129 stop
= mri_comment_field (&stopc
);
3130 abs_section_offset
= get_absolute_expression ();
3131 subseg_set (absolute_section
, 0);
3132 demand_empty_rest_of_line ();
3134 mri_comment_end (stop
, stopc
);
3139 int ignore ATTRIBUTE_UNUSED
;
3143 temp
= get_absolute_expression ();
3144 subseg_set (text_section
, (subsegT
) temp
);
3145 demand_empty_rest_of_line ();
3147 const_flag
&= ~IN_DEFAULT_SECTION
;
3152 demand_empty_rest_of_line ()
3155 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3156 input_line_pointer
++;
3158 ignore_rest_of_line ();
3160 /* Return having already swallowed end-of-line. */
3164 ignore_rest_of_line ()
3166 /* For suspect lines: gives warning. */
3167 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3169 if (ISPRINT (*input_line_pointer
))
3170 as_warn (_("rest of line ignored; first ignored character is `%c'"),
3171 *input_line_pointer
);
3173 as_warn (_("rest of line ignored; first ignored character valued 0x%x"),
3174 *input_line_pointer
);
3176 while (input_line_pointer
< buffer_limit
3177 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3178 input_line_pointer
++;
3181 input_line_pointer
++;
3183 /* Return pointing just after end-of-line. */
3184 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3188 discard_rest_of_line ()
3190 while (input_line_pointer
< buffer_limit
3191 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3192 input_line_pointer
++;
3194 input_line_pointer
++;
3196 /* Return pointing just after end-of-line. */
3197 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3200 /* In: Pointer to a symbol.
3201 Input_line_pointer->expression.
3203 Out: Input_line_pointer->just after any whitespace after expression.
3204 Tried to set symbol to value of expression.
3205 Will change symbols type, value, and frag; */
3208 pseudo_set (symbolP
)
3212 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3214 #endif /* OBJ_AOUT or OBJ_BOUT */
3216 know (symbolP
); /* NULL pointer is logic error. */
3217 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3218 ext
= S_IS_EXTERNAL (symbolP
);
3219 #endif /* OBJ_AOUT or OBJ_BOUT */
3221 (void) expression (&exp
);
3223 if (exp
.X_op
== O_illegal
)
3224 as_bad (_("illegal expression"));
3225 else if (exp
.X_op
== O_absent
)
3226 as_bad (_("missing expression"));
3227 else if (exp
.X_op
== O_big
)
3229 if (exp
.X_add_number
> 0)
3230 as_bad (_("bignum invalid"));
3232 as_bad (_("floating point number invalid"));
3234 else if (exp
.X_op
== O_subtract
3235 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3236 == S_GET_SEGMENT (exp
.X_op_symbol
))
3237 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3238 && (symbol_get_frag (exp
.X_add_symbol
)
3239 == symbol_get_frag (exp
.X_op_symbol
)))
3241 exp
.X_op
= O_constant
;
3242 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3243 - S_GET_VALUE (exp
.X_op_symbol
));
3251 exp
.X_add_number
= 0;
3254 S_SET_SEGMENT (symbolP
, absolute_section
);
3255 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3257 S_SET_EXTERNAL (symbolP
);
3259 S_CLEAR_EXTERNAL (symbolP
);
3260 #endif /* OBJ_AOUT or OBJ_BOUT */
3261 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3262 if (exp
.X_op
!= O_constant
)
3263 symbol_set_frag (symbolP
, &zero_address_frag
);
3267 S_SET_SEGMENT (symbolP
, reg_section
);
3268 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3269 symbol_set_frag (symbolP
, &zero_address_frag
);
3273 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3274 || exp
.X_add_number
!= 0)
3275 symbol_set_value_expression (symbolP
, &exp
);
3276 else if (symbol_section_p (symbolP
))
3277 as_bad ("attempt to set value of section symbol");
3280 symbolS
*s
= exp
.X_add_symbol
;
3282 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3283 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3285 S_SET_EXTERNAL (symbolP
);
3287 S_CLEAR_EXTERNAL (symbolP
);
3288 #endif /* OBJ_AOUT or OBJ_BOUT */
3289 S_SET_VALUE (symbolP
,
3290 exp
.X_add_number
+ S_GET_VALUE (s
));
3291 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3292 copy_symbol_attributes (symbolP
, s
);
3297 /* The value is some complex expression.
3298 FIXME: Should we set the segment to anything? */
3299 symbol_set_value_expression (symbolP
, &exp
);
3306 CONStruct more frag of .bytes, or .words etc.
3307 Should need_pass_2 be 1 then emit no frag(s).
3308 This understands EXPRESSIONS.
3312 This has a split personality. We use expression() to read the
3313 value. We can detect if the value won't fit in a byte or word.
3314 But we can't detect if expression() discarded significant digits
3315 in the case of a long. Not worth the crocks required to fix it. */
3317 /* Select a parser for cons expressions. */
3319 /* Some targets need to parse the expression in various fancy ways.
3320 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3321 (for example, the HPPA does this). Otherwise, you can define
3322 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3323 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3324 are defined, which is the normal case, then only simple expressions
3329 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3332 #ifndef TC_PARSE_CONS_EXPRESSION
3333 #ifdef BITFIELD_CONS_EXPRESSIONS
3334 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3336 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3338 #ifdef REPEAT_CONS_EXPRESSIONS
3339 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3341 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3344 /* If we haven't gotten one yet, just call expression. */
3345 #ifndef TC_PARSE_CONS_EXPRESSION
3346 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3350 /* Worker to do .byte etc statements.
3351 Clobbers input_line_pointer and checks end-of-line. */
3354 cons_worker (nbytes
, rva
)
3355 register int nbytes
; /* 1=.byte, 2=.word, 4=.long. */
3363 #ifdef md_flush_pending_output
3364 md_flush_pending_output ();
3368 stop
= mri_comment_field (&stopc
);
3370 if (is_it_end_of_statement ())
3372 demand_empty_rest_of_line ();
3374 mri_comment_end (stop
, stopc
);
3378 #ifdef md_cons_align
3379 md_cons_align (nbytes
);
3387 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3390 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3394 if (exp
.X_op
== O_symbol
)
3395 exp
.X_op
= O_symbol_rva
;
3397 as_fatal (_("rva without symbol"));
3399 emit_expr (&exp
, (unsigned int) nbytes
);
3402 while (*input_line_pointer
++ == ',');
3404 /* In MRI mode, after an odd number of bytes, we must align to an
3405 even word boundary, unless the next instruction is a dc.b, ds.b
3407 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3408 mri_pending_align
= 1;
3410 input_line_pointer
--; /* Put terminator back into stream. */
3412 demand_empty_rest_of_line ();
3415 mri_comment_end (stop
, stopc
);
3422 cons_worker (size
, 0);
3429 cons_worker (size
, 1);
3432 /* Put the contents of expression EXP into the object file using
3433 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3436 emit_expr (exp
, nbytes
)
3438 unsigned int nbytes
;
3442 valueT extra_digit
= 0;
3444 /* Don't do anything if we are going to make another pass. */
3450 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3451 appear as a four byte positive constant in the .line section,
3452 followed by a 2 byte 0xffff. Look for that case here. */
3454 static int dwarf_line
= -1;
3456 if (strcmp (segment_name (now_seg
), ".line") != 0)
3458 else if (dwarf_line
>= 0
3460 && exp
->X_op
== O_constant
3461 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3462 listing_source_line ((unsigned int) dwarf_line
);
3463 else if (nbytes
== 4
3464 && exp
->X_op
== O_constant
3465 && exp
->X_add_number
>= 0)
3466 dwarf_line
= exp
->X_add_number
;
3471 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3472 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3473 AT_sibling (0x12) followed by a four byte address of the sibling
3474 followed by a 2 byte AT_name (0x38) followed by the name of the
3475 file. We look for that case here. */
3477 static int dwarf_file
= 0;
3479 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3481 else if (dwarf_file
== 0
3483 && exp
->X_op
== O_constant
3484 && exp
->X_add_number
== 0x11)
3486 else if (dwarf_file
== 1
3488 && exp
->X_op
== O_constant
3489 && exp
->X_add_number
== 0x12)
3491 else if (dwarf_file
== 2
3494 else if (dwarf_file
== 3
3496 && exp
->X_op
== O_constant
3497 && exp
->X_add_number
== 0x38)
3502 /* The variable dwarf_file_string tells stringer that the string
3503 may be the name of the source file. */
3504 if (dwarf_file
== 4)
3505 dwarf_file_string
= 1;
3507 dwarf_file_string
= 0;
3512 if (check_eh_frame (exp
, &nbytes
))
3517 /* Allow `.word 0' in the absolute section. */
3518 if (now_seg
== absolute_section
)
3520 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3521 as_bad (_("attempt to store value in absolute section"));
3522 abs_section_offset
+= nbytes
;
3526 /* Handle a negative bignum. */
3528 && exp
->X_add_number
== 0
3529 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3530 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3533 unsigned long carry
;
3535 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3537 /* Negate the bignum: one's complement each digit and add 1. */
3539 for (i
= 0; i
< exp
->X_add_number
; i
++)
3543 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3546 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3547 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3550 /* We can ignore any carry out, because it will be handled by
3551 extra_digit if it is needed. */
3553 extra_digit
= (valueT
) -1;
3557 if (op
== O_absent
|| op
== O_illegal
)
3559 as_warn (_("zero assumed for missing expression"));
3560 exp
->X_add_number
= 0;
3563 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3565 as_bad (_("floating point number invalid"));
3566 exp
->X_add_number
= 0;
3569 else if (op
== O_register
)
3571 as_warn (_("register value used as expression"));
3575 p
= frag_more ((int) nbytes
);
3577 #ifndef WORKING_DOT_WORD
3578 /* If we have the difference of two symbols in a word, save it on
3579 the broken_words list. See the code in write.c. */
3580 if (op
== O_subtract
&& nbytes
== 2)
3582 struct broken_word
*x
;
3584 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3585 x
->next_broken_word
= broken_words
;
3588 x
->subseg
= now_subseg
;
3590 x
->word_goes_here
= p
;
3592 x
->add
= exp
->X_add_symbol
;
3593 x
->sub
= exp
->X_op_symbol
;
3594 x
->addnum
= exp
->X_add_number
;
3601 /* If we have an integer, but the number of bytes is too large to
3602 pass to md_number_to_chars, handle it as a bignum. */
3603 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3608 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3609 extra_digit
= (valueT
) -1;
3610 val
= (valueT
) exp
->X_add_number
;
3614 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3615 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3619 op
= exp
->X_op
= O_big
;
3620 exp
->X_add_number
= gencnt
;
3623 if (op
== O_constant
)
3625 register valueT get
;
3626 register valueT use
;
3627 register valueT mask
;
3629 register valueT unmask
;
3631 /* JF << of >= number of bits in the object is undefined. In
3632 particular SPARC (Sun 4) has problems. */
3633 if (nbytes
>= sizeof (valueT
))
3636 if (nbytes
> sizeof (valueT
))
3639 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3643 /* Don't store these bits. */
3644 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3645 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3648 unmask
= ~mask
; /* Do store these bits. */
3651 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3652 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3655 get
= exp
->X_add_number
;
3657 if ((get
& mask
) != 0
3658 && ((get
& mask
) != mask
3659 || (get
& hibit
) == 0))
3660 { /* Leading bits contain both 0s & 1s. */
3661 as_warn (_("value 0x%lx truncated to 0x%lx"),
3662 (unsigned long) get
, (unsigned long) use
);
3664 /* Put bytes in right order. */
3665 md_number_to_chars (p
, use
, (int) nbytes
);
3667 else if (op
== O_big
)
3670 LITTLENUM_TYPE
*nums
;
3672 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3674 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3677 as_warn (_("bignum truncated to %d bytes"), nbytes
);
3681 if (target_big_endian
)
3683 while (nbytes
> size
)
3685 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3686 nbytes
-= CHARS_PER_LITTLENUM
;
3687 p
+= CHARS_PER_LITTLENUM
;
3690 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3691 while (size
>= CHARS_PER_LITTLENUM
)
3694 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3695 size
-= CHARS_PER_LITTLENUM
;
3696 p
+= CHARS_PER_LITTLENUM
;
3701 nums
= generic_bignum
;
3702 while (size
>= CHARS_PER_LITTLENUM
)
3704 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3706 size
-= CHARS_PER_LITTLENUM
;
3707 p
+= CHARS_PER_LITTLENUM
;
3708 nbytes
-= CHARS_PER_LITTLENUM
;
3711 while (nbytes
>= CHARS_PER_LITTLENUM
)
3713 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3714 nbytes
-= CHARS_PER_LITTLENUM
;
3715 p
+= CHARS_PER_LITTLENUM
;
3721 memset (p
, 0, nbytes
);
3723 /* Now we need to generate a fixS to record the symbol value.
3724 This is easy for BFD. For other targets it can be more
3725 complex. For very complex cases (currently, the HPPA and
3726 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3727 want. For simpler cases, you can define TC_CONS_RELOC to be
3728 the name of the reloc code that should be stored in the fixS.
3729 If neither is defined, the code uses NO_RELOC if it is
3730 defined, and otherwise uses 0. */
3732 #ifdef BFD_ASSEMBLER
3733 #ifdef TC_CONS_FIX_NEW
3734 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3737 bfd_reloc_code_real_type r
;
3754 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3758 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3763 #ifdef TC_CONS_FIX_NEW
3764 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3766 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3767 it is defined, otherwise use NO_RELOC if it is defined,
3769 #ifndef TC_CONS_RELOC
3771 #define TC_CONS_RELOC NO_RELOC
3773 #define TC_CONS_RELOC 0
3776 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3778 #endif /* TC_CONS_FIX_NEW */
3779 #endif /* BFD_ASSEMBLER */
3783 #ifdef BITFIELD_CONS_EXPRESSIONS
3785 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3786 w:x,y:z, where w and y are bitwidths and x and y are values. They
3787 then pack them all together. We do a little better in that we allow
3788 them in words, longs, etc. and we'll pack them in target byte order
3791 The rules are: pack least significat bit first, if a field doesn't
3792 entirely fit, put it in the next unit. Overflowing the bitfield is
3793 explicitly *not* even a warning. The bitwidth should be considered
3796 To use this function the tc-XXX.h file should define
3797 BITFIELD_CONS_EXPRESSIONS. */
3800 parse_bitfield_cons (exp
, nbytes
)
3802 unsigned int nbytes
;
3804 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3805 char *hold
= input_line_pointer
;
3807 (void) expression (exp
);
3809 if (*input_line_pointer
== ':')
3816 unsigned long width
;
3818 if (*input_line_pointer
!= ':')
3820 input_line_pointer
= hold
;
3822 } /* Next piece is not a bitfield. */
3824 /* In the general case, we can't allow
3825 full expressions with symbol
3826 differences and such. The relocation
3827 entries for symbols not defined in this
3828 assembly would require arbitrary field
3829 widths, positions, and masks which most
3830 of our current object formats don't
3833 In the specific case where a symbol
3834 *is* defined in this assembly, we
3835 *could* build fixups and track it, but
3836 this could lead to confusion for the
3837 backends. I'm lazy. I'll take any
3838 SEG_ABSOLUTE. I think that means that
3839 you can use a previous .set or
3840 .equ type symbol. xoxorich. */
3842 if (exp
->X_op
== O_absent
)
3844 as_warn (_("using a bit field width of zero"));
3845 exp
->X_add_number
= 0;
3846 exp
->X_op
= O_constant
;
3847 } /* Implied zero width bitfield. */
3849 if (exp
->X_op
!= O_constant
)
3851 *input_line_pointer
= '\0';
3852 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3853 *input_line_pointer
= ':';
3854 demand_empty_rest_of_line ();
3856 } /* Too complex. */
3858 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3860 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3861 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3862 width
= BITS_PER_CHAR
* nbytes
;
3865 if (width
> bits_available
)
3867 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3868 input_line_pointer
= hold
;
3869 exp
->X_add_number
= value
;
3874 hold
= ++input_line_pointer
;
3876 (void) expression (exp
);
3877 if (exp
->X_op
!= O_constant
)
3879 char cache
= *input_line_pointer
;
3881 *input_line_pointer
= '\0';
3882 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3883 *input_line_pointer
= cache
;
3884 demand_empty_rest_of_line ();
3886 } /* Too complex. */
3888 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3889 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3891 if ((bits_available
-= width
) == 0
3892 || is_it_end_of_statement ()
3893 || *input_line_pointer
!= ',')
3896 } /* All the bitfields we're gonna get. */
3898 hold
= ++input_line_pointer
;
3899 (void) expression (exp
);
3902 exp
->X_add_number
= value
;
3903 exp
->X_op
= O_constant
;
3904 exp
->X_unsigned
= 1;
3908 #endif /* BITFIELD_CONS_EXPRESSIONS */
3910 /* Handle an MRI style string expression. */
3914 parse_mri_cons (exp
, nbytes
)
3916 unsigned int nbytes
;
3918 if (*input_line_pointer
!= '\''
3919 && (input_line_pointer
[1] != '\''
3920 || (*input_line_pointer
!= 'A'
3921 && *input_line_pointer
!= 'E')))
3922 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3926 unsigned int result
= 0;
3928 /* An MRI style string. Cut into as many bytes as will fit into
3929 a nbyte chunk, left justify if necessary, and separate with
3930 commas so we can try again later. */
3931 if (*input_line_pointer
== 'A')
3932 ++input_line_pointer
;
3933 else if (*input_line_pointer
== 'E')
3935 as_bad (_("EBCDIC constants are not supported"));
3936 ++input_line_pointer
;
3939 input_line_pointer
++;
3940 for (scan
= 0; scan
< nbytes
; scan
++)
3942 if (*input_line_pointer
== '\'')
3944 if (input_line_pointer
[1] == '\'')
3946 input_line_pointer
++;
3951 result
= (result
<< 8) | (*input_line_pointer
++);
3955 while (scan
< nbytes
)
3961 /* Create correct expression. */
3962 exp
->X_op
= O_constant
;
3963 exp
->X_add_number
= result
;
3965 /* Fake it so that we can read the next char too. */
3966 if (input_line_pointer
[0] != '\'' ||
3967 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3969 input_line_pointer
-= 2;
3970 input_line_pointer
[0] = ',';
3971 input_line_pointer
[1] = '\'';
3974 input_line_pointer
++;
3977 #endif /* TC_M68K */
3979 #ifdef REPEAT_CONS_EXPRESSIONS
3981 /* Parse a repeat expression for cons. This is used by the MIPS
3982 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3983 object file COUNT times.
3985 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3988 parse_repeat_cons (exp
, nbytes
)
3990 unsigned int nbytes
;
3997 if (*input_line_pointer
!= ':')
3999 /* No repeat count. */
4003 ++input_line_pointer
;
4004 expression (&count
);
4005 if (count
.X_op
!= O_constant
4006 || count
.X_add_number
<= 0)
4008 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4012 /* The cons function is going to output this expression once. So we
4013 output it count - 1 times. */
4014 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
4015 emit_expr (exp
, nbytes
);
4018 #endif /* REPEAT_CONS_EXPRESSIONS */
4020 /* Parse a floating point number represented as a hex constant. This
4021 permits users to specify the exact bits they want in the floating
4025 hex_float (float_type
, bytes
)
4059 as_bad (_("unknown floating type type '%c'"), float_type
);
4063 /* It would be nice if we could go through expression to parse the
4064 hex constant, but if we get a bignum it's a pain to sort it into
4065 the buffer correctly. */
4067 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4071 /* The MRI assembler accepts arbitrary underscores strewn about
4072 through the hex constant, so we ignore them as well. */
4073 if (*input_line_pointer
== '_')
4075 ++input_line_pointer
;
4081 as_warn (_("floating point constant too large"));
4084 d
= hex_value (*input_line_pointer
) << 4;
4085 ++input_line_pointer
;
4086 while (*input_line_pointer
== '_')
4087 ++input_line_pointer
;
4088 if (hex_p (*input_line_pointer
))
4090 d
+= hex_value (*input_line_pointer
);
4091 ++input_line_pointer
;
4093 if (target_big_endian
)
4096 bytes
[length
- i
- 1] = d
;
4102 if (target_big_endian
)
4103 memset (bytes
+ i
, 0, length
- i
);
4105 memset (bytes
, 0, length
- i
);
4113 CONStruct some more frag chars of .floats .ffloats etc.
4114 Makes 0 or more new frags.
4115 If need_pass_2 == 1, no frags are emitted.
4116 This understands only floating literals, not expressions. Sorry.
4118 A floating constant is defined by atof_generic(), except it is preceded
4119 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4120 reading, I decided to be incompatible. This always tries to give you
4121 rounded bits to the precision of the pseudo-op. Former AS did premature
4122 truncatation, restored noisy bits instead of trailing 0s AND gave you
4123 a choice of 2 flavours of noise according to which of 2 floating-point
4124 scanners you directed AS to use.
4126 In: input_line_pointer->whitespace before, or '0' of flonum. */
4129 float_cons (float_type
)
4130 /* Clobbers input_line-pointer, checks end-of-line. */
4131 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4134 int length
; /* Number of chars in an object. */
4135 register char *err
; /* Error from scanning floating literal. */
4136 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4138 if (is_it_end_of_statement ())
4140 demand_empty_rest_of_line ();
4144 #ifdef md_flush_pending_output
4145 md_flush_pending_output ();
4150 /* input_line_pointer->1st char of a flonum (we hope!). */
4153 /* Skip any 0{letter} that may be present. Don't even check if the
4154 letter is legal. Someone may invent a "z" format and this routine
4155 has no use for such information. Lusers beware: you get
4156 diagnostics if your input is ill-conditioned. */
4157 if (input_line_pointer
[0] == '0'
4158 && ISALPHA (input_line_pointer
[1]))
4159 input_line_pointer
+= 2;
4161 /* Accept :xxxx, where the x's are hex digits, for a floating
4162 point with the exact digits specified. */
4163 if (input_line_pointer
[0] == ':')
4165 ++input_line_pointer
;
4166 length
= hex_float (float_type
, temp
);
4169 ignore_rest_of_line ();
4175 err
= md_atof (float_type
, temp
, &length
);
4176 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4180 as_bad (_("bad floating literal: %s"), err
);
4181 ignore_rest_of_line ();
4192 #ifdef REPEAT_CONS_EXPRESSIONS
4193 if (*input_line_pointer
== ':')
4195 expressionS count_exp
;
4197 ++input_line_pointer
;
4198 expression (&count_exp
);
4200 if (count_exp
.X_op
!= O_constant
4201 || count_exp
.X_add_number
<= 0)
4202 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4204 count
= count_exp
.X_add_number
;
4208 while (--count
>= 0)
4210 p
= frag_more (length
);
4211 memcpy (p
, temp
, (unsigned int) length
);
4216 while (*input_line_pointer
++ == ',');
4218 /* Put terminator back into stream. */
4219 --input_line_pointer
;
4220 demand_empty_rest_of_line ();
4223 /* Return the size of a LEB128 value. */
4226 sizeof_sleb128 (value
)
4229 register int size
= 0;
4230 register unsigned byte
;
4234 byte
= (value
& 0x7f);
4235 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4236 Fortunately, we can structure things so that the extra work reduces
4237 to a noop on systems that do things "properly". */
4238 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4241 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4242 || ((value
== -1) && ((byte
& 0x40) != 0))));
4248 sizeof_uleb128 (value
)
4251 register int size
= 0;
4252 register unsigned byte
;
4256 byte
= (value
& 0x7f);
4266 sizeof_leb128 (value
, sign
)
4271 return sizeof_sleb128 ((offsetT
) value
);
4273 return sizeof_uleb128 (value
);
4276 /* Output a LEB128 value. */
4279 output_sleb128 (p
, value
)
4283 register char *orig
= p
;
4288 unsigned byte
= (value
& 0x7f);
4290 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4291 Fortunately, we can structure things so that the extra work reduces
4292 to a noop on systems that do things "properly". */
4293 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4295 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4296 || ((value
== -1) && ((byte
& 0x40) != 0))));
4308 output_uleb128 (p
, value
)
4316 unsigned byte
= (value
& 0x7f);
4319 /* More bytes to follow. */
4330 output_leb128 (p
, value
, sign
)
4336 return output_sleb128 (p
, (offsetT
) value
);
4338 return output_uleb128 (p
, value
);
4341 /* Do the same for bignums. We combine sizeof with output here in that
4342 we don't output for NULL values of P. It isn't really as critical as
4343 for "normal" values that this be streamlined. */
4346 output_big_sleb128 (p
, bignum
, size
)
4348 LITTLENUM_TYPE
*bignum
;
4356 /* Strip leading sign extensions off the bignum. */
4357 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4362 if (loaded
< 7 && size
> 0)
4364 val
|= (*bignum
<< loaded
);
4365 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4376 if ((val
== 0 && (byte
& 0x40) == 0)
4377 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4378 && (byte
& 0x40) != 0))
4386 while (byte
& 0x80);
4392 output_big_uleb128 (p
, bignum
, size
)
4394 LITTLENUM_TYPE
*bignum
;
4402 /* Strip leading zeros off the bignum. */
4403 /* XXX: Is this needed? */
4404 while (size
> 0 && bignum
[size
- 1] == 0)
4409 if (loaded
< 7 && size
> 0)
4411 val
|= (*bignum
<< loaded
);
4412 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4421 if (size
> 0 || val
)
4428 while (byte
& 0x80);
4434 output_big_leb128 (p
, bignum
, size
, sign
)
4436 LITTLENUM_TYPE
*bignum
;
4440 return output_big_sleb128 (p
, bignum
, size
);
4442 return output_big_uleb128 (p
, bignum
, size
);
4445 /* Generate the appropriate fragments for a given expression to emit a
4449 emit_leb128_expr (exp
, sign
)
4453 operatorT op
= exp
->X_op
;
4456 if (op
== O_absent
|| op
== O_illegal
)
4458 as_warn (_("zero assumed for missing expression"));
4459 exp
->X_add_number
= 0;
4462 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4464 as_bad (_("floating point number invalid"));
4465 exp
->X_add_number
= 0;
4468 else if (op
== O_register
)
4470 as_warn (_("register value used as expression"));
4474 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
4475 a signal that this is leb128 data. It shouldn't optimize this away. */
4477 if (check_eh_frame (exp
, &nbytes
))
4480 /* Let the backend know that subsequent data may be byte aligned. */
4481 #ifdef md_cons_align
4485 if (op
== O_constant
)
4487 /* If we've got a constant, emit the thing directly right now. */
4489 valueT value
= exp
->X_add_number
;
4493 size
= sizeof_leb128 (value
, sign
);
4494 p
= frag_more (size
);
4495 output_leb128 (p
, value
, sign
);
4497 else if (op
== O_big
)
4499 /* O_big is a different sort of constant. */
4504 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4505 p
= frag_more (size
);
4506 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4510 /* Otherwise, we have to create a variable sized fragment and
4511 resolve things later. */
4513 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4514 make_expr_symbol (exp
), 0, (char *) NULL
);
4518 /* Parse the .sleb128 and .uleb128 pseudos. */
4529 emit_leb128_expr (&exp
, sign
);
4531 while (*input_line_pointer
++ == ',');
4533 input_line_pointer
--;
4534 demand_empty_rest_of_line ();
4537 /* We read 0 or more ',' separated, double-quoted strings.
4538 Caller should have checked need_pass_2 is FALSE because we don't
4542 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4543 /* Checks end-of-line. */
4544 register int append_zero
; /* 0: don't append '\0', else 1. */
4546 register unsigned int c
;
4549 #ifdef md_flush_pending_output
4550 md_flush_pending_output ();
4553 /* The following awkward logic is to parse ZERO or more strings,
4554 comma separated. Recall a string expression includes spaces
4555 before the opening '\"' and spaces after the closing '\"'.
4556 We fake a leading ',' if there is (supposed to be)
4557 a 1st, expression. We keep demanding expressions for each ','. */
4558 if (is_it_end_of_statement ())
4560 c
= 0; /* Skip loop. */
4561 ++input_line_pointer
; /* Compensate for end of loop. */
4565 c
= ','; /* Do loop. */
4567 while (c
== ',' || c
== '<' || c
== '"')
4570 switch (*input_line_pointer
)
4573 ++input_line_pointer
; /*->1st char of string. */
4574 start
= input_line_pointer
;
4575 while (is_a_char (c
= next_char_of_string ()))
4577 FRAG_APPEND_1_CHAR (c
);
4581 FRAG_APPEND_1_CHAR (0);
4583 know (input_line_pointer
[-1] == '\"');
4587 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4588 will emit .string with a filename in the .debug section
4589 after a sequence of constants. See the comment in
4590 emit_expr for the sequence. emit_expr will set
4591 dwarf_file_string to non-zero if this string might be a
4592 source file name. */
4593 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4594 dwarf_file_string
= 0;
4595 else if (dwarf_file_string
)
4597 c
= input_line_pointer
[-1];
4598 input_line_pointer
[-1] = '\0';
4599 listing_source_file (start
);
4600 input_line_pointer
[-1] = c
;
4607 input_line_pointer
++;
4608 c
= get_single_number ();
4609 FRAG_APPEND_1_CHAR (c
);
4610 if (*input_line_pointer
!= '>')
4612 as_bad (_("expected <nn>"));
4614 input_line_pointer
++;
4617 input_line_pointer
++;
4621 c
= *input_line_pointer
;
4624 demand_empty_rest_of_line ();
4627 /* FIXME-SOMEDAY: I had trouble here on characters with the
4628 high bits set. We'll probably also have trouble with
4629 multibyte chars, wide chars, etc. Also be careful about
4630 returning values bigger than 1 byte. xoxorich. */
4633 next_char_of_string ()
4635 register unsigned int c
;
4637 c
= *input_line_pointer
++ & CHAR_MASK
;
4645 as_warn (_("unterminated string; newline inserted"));
4646 bump_line_counters ();
4649 #ifndef NO_STRING_ESCAPES
4651 switch (c
= *input_line_pointer
++)
4679 break; /* As itself. */
4695 for (i
= 0, number
= 0;
4696 ISDIGIT (c
) && i
< 3;
4697 c
= *input_line_pointer
++, i
++)
4699 number
= number
* 8 + c
- '0';
4704 --input_line_pointer
;
4713 c
= *input_line_pointer
++;
4714 while (ISXDIGIT (c
))
4717 number
= number
* 16 + c
- '0';
4718 else if (ISUPPER (c
))
4719 number
= number
* 16 + c
- 'A' + 10;
4721 number
= number
* 16 + c
- 'a' + 10;
4722 c
= *input_line_pointer
++;
4725 --input_line_pointer
;
4730 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4731 as_warn (_("unterminated string; newline inserted"));
4733 bump_line_counters ();
4738 #ifdef ONLY_STANDARD_ESCAPES
4739 as_bad (_("bad escaped character in string"));
4741 #endif /* ONLY_STANDARD_ESCAPES */
4746 #endif /* ! defined (NO_STRING_ESCAPES) */
4755 get_segmented_expression (expP
)
4756 register expressionS
*expP
;
4758 register segT retval
;
4760 retval
= expression (expP
);
4761 if (expP
->X_op
== O_illegal
4762 || expP
->X_op
== O_absent
4763 || expP
->X_op
== O_big
)
4765 as_bad (_("expected address expression"));
4766 expP
->X_op
= O_constant
;
4767 expP
->X_add_number
= 0;
4768 retval
= absolute_section
;
4774 get_known_segmented_expression (expP
)
4775 register expressionS
*expP
;
4777 register segT retval
;
4779 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4781 /* There is no easy way to extract the undefined symbol from the
4783 if (expP
->X_add_symbol
!= NULL
4784 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4785 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4786 S_GET_NAME (expP
->X_add_symbol
));
4788 as_warn (_("some symbol undefined; zero assumed"));
4789 retval
= absolute_section
;
4790 expP
->X_op
= O_constant
;
4791 expP
->X_add_number
= 0;
4793 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4798 get_absolute_expression ()
4803 if (exp
.X_op
!= O_constant
)
4805 if (exp
.X_op
!= O_absent
)
4806 as_bad (_("bad or irreducible absolute expression"));
4807 exp
.X_add_number
= 0;
4809 return exp
.X_add_number
;
4812 char /* Return terminator. */
4813 get_absolute_expression_and_terminator (val_pointer
)
4814 long *val_pointer
; /* Return value of expression. */
4816 /* FIXME: val_pointer should probably be offsetT *. */
4817 *val_pointer
= (long) get_absolute_expression ();
4818 return (*input_line_pointer
++);
4821 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4822 Give a warning if that happens. */
4825 demand_copy_C_string (len_pointer
)
4830 if ((s
= demand_copy_string (len_pointer
)) != 0)
4834 for (len
= *len_pointer
; len
> 0; len
--)
4841 as_bad (_("this string may not contain \'\\0\'"));
4849 /* Demand string, but return a safe (=private) copy of the string.
4850 Return NULL if we can't read a string here. */
4853 demand_copy_string (lenP
)
4856 register unsigned int c
;
4862 if (*input_line_pointer
== '\"')
4864 input_line_pointer
++; /* Skip opening quote. */
4866 while (is_a_char (c
= next_char_of_string ()))
4868 obstack_1grow (¬es
, c
);
4871 /* JF this next line is so demand_copy_C_string will return a
4872 null terminated string. */
4873 obstack_1grow (¬es
, '\0');
4874 retval
= obstack_finish (¬es
);
4878 as_warn (_("missing string"));
4880 ignore_rest_of_line ();
4886 /* In: Input_line_pointer->next character.
4888 Do: Skip input_line_pointer over all whitespace.
4890 Out: 1 if input_line_pointer->end-of-line. */
4893 is_it_end_of_statement ()
4896 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4900 equals (sym_name
, reassign
)
4904 register symbolS
*symbolP
; /* Symbol we are working with. */
4908 input_line_pointer
++;
4909 if (*input_line_pointer
== '=')
4910 input_line_pointer
++;
4912 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4913 input_line_pointer
++;
4916 stop
= mri_comment_field (&stopc
);
4918 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4920 /* Turn '. = mumble' into a .org mumble. */
4921 register segT segment
;
4924 segment
= get_known_segmented_expression (&exp
);
4926 do_org (segment
, &exp
, 0);
4933 symbolP
= symbol_find (sym_name
);
4934 local
= symbolP
== NULL
;
4936 #endif /* OBJ_COFF */
4937 symbolP
= symbol_find_or_make (sym_name
);
4938 /* Permit register names to be redefined. */
4940 && S_IS_DEFINED (symbolP
)
4941 && S_GET_SEGMENT (symbolP
) != reg_section
)
4942 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
4945 /* "set" symbols are local unless otherwise specified. */
4947 SF_SET_LOCAL (symbolP
);
4948 #endif /* OBJ_COFF */
4950 pseudo_set (symbolP
);
4955 /* Check garbage after the expression. */
4956 ignore_rest_of_line ();
4957 mri_comment_end (stop
, stopc
);
4961 /* .incbin -- include a file verbatim at the current location. */
4965 int x ATTRIBUTE_UNUSED
;
4976 #ifdef md_flush_pending_output
4977 md_flush_pending_output ();
4981 filename
= demand_copy_string (& len
);
4982 if (filename
== NULL
)
4987 /* Look for optional skip and count. */
4988 if (* input_line_pointer
== ',')
4990 ++ input_line_pointer
;
4991 skip
= get_absolute_expression ();
4995 if (* input_line_pointer
== ',')
4997 ++ input_line_pointer
;
4999 count
= get_absolute_expression ();
5001 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
5007 demand_empty_rest_of_line ();
5009 /* Try opening absolute path first, then try include dirs. */
5010 binfile
= fopen (filename
, FOPEN_RB
);
5011 if (binfile
== NULL
)
5015 path
= xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
5017 for (i
= 0; i
< include_dir_count
; i
++)
5019 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
5021 binfile
= fopen (path
, FOPEN_RB
);
5022 if (binfile
!= NULL
)
5026 if (binfile
== NULL
)
5027 as_bad (_("file not found: %s"), filename
);
5030 path
= xstrdup (filename
);
5036 register_dependency (path
);
5038 /* Compute the length of the file. */
5039 if (fseek (binfile
, 0, SEEK_END
) != 0)
5041 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
5044 file_len
= ftell (binfile
);
5046 /* If a count was not specified use the size of the file. */
5050 if (skip
+ count
> file_len
)
5052 as_bad (_("skip (%ld) + count (%ld) larger than file size (%ld)"),
5053 skip
, count
, file_len
);
5057 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
5059 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
5063 /* Allocate frag space and store file contents in it. */
5064 binfrag
= frag_more (count
);
5066 bytes
= fread (binfrag
, 1, count
, binfile
);
5068 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5069 path
, bytes
, count
);
5072 if (binfile
!= NULL
)
5078 /* .include -- include a file at this point. */
5082 int arg ATTRIBUTE_UNUSED
;
5091 filename
= demand_copy_string (&i
);
5092 if (filename
== NULL
)
5094 /* demand_copy_string has already printed an error and
5095 called ignore_rest_of_line. */
5103 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5104 && *input_line_pointer
!= ' '
5105 && *input_line_pointer
!= '\t')
5107 obstack_1grow (¬es
, *input_line_pointer
);
5108 ++input_line_pointer
;
5112 obstack_1grow (¬es
, '\0');
5113 filename
= obstack_finish (¬es
);
5114 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5115 ++input_line_pointer
;
5118 demand_empty_rest_of_line ();
5119 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
5121 for (i
= 0; i
< include_dir_count
; i
++)
5123 strcpy (path
, include_dirs
[i
]);
5125 strcat (path
, filename
);
5126 if (0 != (try = fopen (path
, FOPEN_RT
)))
5136 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5137 register_dependency (path
);
5138 input_scrub_insert_file (path
);
5142 add_include_dir (path
)
5147 if (include_dir_count
== 0)
5149 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5150 include_dirs
[0] = "."; /* Current dir. */
5151 include_dir_count
= 2;
5155 include_dir_count
++;
5157 (char **) realloc (include_dirs
,
5158 include_dir_count
* sizeof (*include_dirs
));
5161 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5164 if (i
> include_dir_maxlen
)
5165 include_dir_maxlen
= i
;
5168 /* Output debugging information to denote the source file. */
5171 generate_file_debug ()
5173 if (debug_type
== DEBUG_STABS
)
5174 stabs_generate_asm_file ();
5177 /* Output line number debugging information for the current source line. */
5180 generate_lineno_debug ()
5184 case DEBUG_UNSPECIFIED
:
5189 stabs_generate_asm_lineno ();
5192 ecoff_generate_asm_lineno ();
5195 /* ??? We could here indicate to dwarf2dbg.c that something
5196 has changed. However, since there is additional backend
5197 support that is required (calling dwarf2_emit_insn), we
5198 let dwarf2dbg.c call as_where on its own. */
5203 /* Output debugging information to mark a function entry point or end point.
5204 END_P is zero for .func, and non-zero for .endfunc. */
5210 do_s_func (end_p
, NULL
);
5213 /* Subroutine of s_func so targets can choose a different default prefix.
5214 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5217 do_s_func (end_p
, default_prefix
)
5219 const char *default_prefix
;
5221 /* Record the current function so that we can issue an error message for
5222 misplaced .func,.endfunc, and also so that .endfunc needs no
5224 static char *current_name
;
5225 static char *current_label
;
5229 if (current_name
== NULL
)
5231 as_bad (_("missing .func"));
5232 ignore_rest_of_line ();
5236 if (debug_type
== DEBUG_STABS
)
5237 stabs_generate_asm_endfunc (current_name
, current_label
);
5239 current_name
= current_label
= NULL
;
5244 char delim1
, delim2
;
5246 if (current_name
!= NULL
)
5248 as_bad (_(".endfunc missing for previous .func"));
5249 ignore_rest_of_line ();
5253 name
= input_line_pointer
;
5254 delim1
= get_symbol_end ();
5255 name
= xstrdup (name
);
5256 *input_line_pointer
= delim1
;
5258 if (*input_line_pointer
!= ',')
5261 asprintf (&label
, "%s%s", default_prefix
, name
);
5264 char leading_char
= 0;
5265 #ifdef BFD_ASSEMBLER
5266 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5268 /* Missing entry point, use function's name with the leading
5271 asprintf (&label
, "%c%s", leading_char
, name
);
5278 ++input_line_pointer
;
5280 label
= input_line_pointer
;
5281 delim2
= get_symbol_end ();
5282 label
= xstrdup (label
);
5283 *input_line_pointer
= delim2
;
5286 if (debug_type
== DEBUG_STABS
)
5287 stabs_generate_asm_func (name
, label
);
5289 current_name
= name
;
5290 current_label
= label
;
5293 demand_empty_rest_of_line ();
5298 int arg ATTRIBUTE_UNUSED
;
5300 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5302 ++input_line_pointer
;
5304 ++input_line_pointer
;
5308 read_print_statistics (file
)
5311 hash_print_statistics (file
, "pseudo-op table", po_hash
);
5314 /* Inserts the given line into the input stream.
5316 This call avoids macro/conditionals nesting checking, since the contents of
5317 the line are assumed to replace the contents of a line already scanned.
5319 An appropriate use of this function would be substition of input lines when
5320 called by md_start_line_hook(). The given line is assumed to already be
5321 properly scrubbed. */
5324 input_scrub_insert_line (line
)
5329 sb_add_string (&newline
, line
);
5330 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
5332 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
5335 /* Insert a file into the input stream; the path must resolve to an actual
5336 file; no include path searching or dependency registering is performed. */
5339 input_scrub_insert_file (path
)
5342 input_scrub_include_file (path
, input_line_pointer
);
5343 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);