1 /* read.c - read a source file -
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* If your chars aren't 8 bits, you will change this a bit.
24 But then, GNU isn't spozed to run on your machine anyway.
25 (RMS is so shortsighted sometimes.) */
26 #define MASK_CHAR (0xFF)
28 #define MASK_CHAR ((int)(unsigned char) -1)
31 /* This is the largest known floating point format (for now). It will
32 grow when we do 4361 style flonums. */
33 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
35 /* Routines that read assembler source text to build spagetti in memory.
36 Another group of these functions is in the expr.c module. */
49 #ifndef TC_START_LABEL
50 #define TC_START_LABEL(x,y) (x==':')
53 /* Set by the object-format or the target. */
54 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
55 #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
60 else if ((SIZE) >= 4) \
62 else if ((SIZE) >= 2) \
70 char *input_line_pointer
; /*->next char of source file to parse. */
72 #if BITS_PER_CHAR != 8
73 /* The following table is indexed by[(char)] and will break if
74 a char does not have exactly 256 states (hopefully 0:255!)! */
79 /* The m88k unfortunately uses @ as a label beginner. */
84 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
89 /* The Delta 68k assembler permits % inside label names. */
94 /* The PowerPC Windows NT assemblers permits ? inside label names. */
99 /* The IA-64 assembler uses # as a suffix designating a symbol. We include
100 it in the symbol and strip it out in tc_canonicalize_symbol_name. */
105 /* The a29k assembler does not permits labels to start with $. */
110 /* The Delta 68k assembler permits ~ at start of label names. */
114 /* Used by is_... macros. our ctype[]. */
115 char lex_type
[256] = {
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
118 0, 0, 0, LEX_HASH
, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
119 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
120 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
121 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
122 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
123 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
124 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
125 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
126 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
127 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
128 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
129 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
130 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
131 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
135 Out: 1 if this character ends a line. */
136 char is_end_of_line
[256] = {
138 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, /* @abcdefghijklmno */
140 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* @abcdefghijklmno */
142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* _!"#$%&'()*+,-./ */
144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
145 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
146 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
149 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
150 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* */
159 #ifdef IGNORE_OPCODE_CASE
160 char original_case_string
[128];
163 /* Functions private to this file. */
165 static char *buffer
; /* 1st char of each buffer of lines is here. */
166 static char *buffer_limit
; /*->1 + last char in buffer. */
168 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
169 in the tc-<CPU>.h file. See the "Porting GAS" section of the
171 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
173 static char *old_buffer
; /* JF a hack. */
174 static char *old_input
;
175 static char *old_limit
;
177 /* Variables for handling include file directory table. */
179 /* Table of pointers to directories to search for .include's. */
182 /* How many are in the table. */
183 int include_dir_count
;
185 /* Length of longest in table. */
186 int include_dir_maxlen
= 1;
188 #ifndef WORKING_DOT_WORD
189 struct broken_word
*broken_words
;
190 int new_broken_words
;
193 /* The current offset into the absolute section. We don't try to
194 build frags in the absolute section, since no data can be stored
195 there. We just keep track of the current offset. */
196 addressT abs_section_offset
;
198 /* If this line had an MRI style label, it is stored in this variable.
199 This is used by some of the MRI pseudo-ops. */
202 /* This global variable is used to support MRI common sections. We
203 translate such sections into a common symbol. This variable is
204 non-NULL when we are in an MRI common section. */
205 symbolS
*mri_common_symbol
;
207 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
208 need to align to an even byte boundary unless the next pseudo-op is
209 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
211 static int mri_pending_align
;
215 /* This variable is set to be non-zero if the next string we see might
216 be the name of the source file in DWARF debugging information. See
217 the comment in emit_expr for the format we look for. */
218 static int dwarf_file_string
;
222 static void cons_worker
PARAMS ((int, int));
223 static int scrub_from_string
PARAMS ((char *, int));
224 static void do_align
PARAMS ((int, char *, int, int));
225 static void s_align
PARAMS ((int, int));
226 static void s_lcomm_internal
PARAMS ((int, int));
227 static int hex_float
PARAMS ((int, char *));
228 static inline int sizeof_sleb128
PARAMS ((offsetT
));
229 static inline int sizeof_uleb128
PARAMS ((valueT
));
230 static inline int output_sleb128
PARAMS ((char *, offsetT
));
231 static inline int output_uleb128
PARAMS ((char *, valueT
));
232 static inline int output_big_sleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
233 static inline int output_big_uleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
234 static int output_big_leb128
PARAMS ((char *, LITTLENUM_TYPE
*, int, int));
235 static void do_org
PARAMS ((segT
, expressionS
*, int));
236 char *demand_copy_string
PARAMS ((int *lenP
));
237 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
238 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
239 static void pobegin
PARAMS ((void));
240 static int get_line_sb
PARAMS ((sb
*));
241 static void generate_file_debug
PARAMS ((void));
249 obj_read_begin_hook ();
251 /* Something close -- but not too close -- to a multiple of 1024.
252 The debugging malloc I'm using has 24 bytes of overhead. */
253 obstack_begin (¬es
, chunksize
);
254 obstack_begin (&cond_obstack
, chunksize
);
256 /* Use machine dependent syntax. */
257 for (p
= line_separator_chars
; *p
; p
++)
258 is_end_of_line
[(unsigned char) *p
] = 1;
259 /* Use more. FIXME-SOMEDAY. */
265 /* Set up pseudo-op tables. */
267 static struct hash_control
*po_hash
;
269 static const pseudo_typeS potable
[] = {
270 {"abort", s_abort
, 0},
271 {"align", s_align_ptwo
, 0},
272 {"ascii", stringer
, 0},
273 {"asciz", stringer
, 1},
274 {"balign", s_align_bytes
, 0},
275 {"balignw", s_align_bytes
, -2},
276 {"balignl", s_align_bytes
, -4},
280 {"common", s_mri_common
, 0},
281 {"common.s", s_mri_common
, 1},
285 {"dc.d", float_cons
, 'd'},
287 {"dc.s", float_cons
, 'f'},
289 {"dc.x", float_cons
, 'x'},
291 {"dcb.b", s_space
, 1},
292 {"dcb.d", s_float_space
, 'd'},
293 {"dcb.l", s_space
, 4},
294 {"dcb.s", s_float_space
, 'f'},
295 {"dcb.w", s_space
, 2},
296 {"dcb.x", s_float_space
, 'x'},
298 {"ds.b", s_space
, 1},
299 {"ds.d", s_space
, 8},
300 {"ds.l", s_space
, 4},
301 {"ds.p", s_space
, 12},
302 {"ds.s", s_space
, 4},
303 {"ds.w", s_space
, 2},
304 {"ds.x", s_space
, 12},
305 {"debug", s_ignore
, 0},
310 {"double", float_cons
, 'd'},
312 {"eject", listing_eject
, 0}, /* Formfeed listing. */
314 {"elsec", s_else
, 0},
315 {"elseif", s_elseif
, (int) O_ne
},
317 {"endc", s_endif
, 0},
318 {"endfunc", s_func
, 1},
319 {"endif", s_endif
, 0},
324 {"exitm", s_mexit
, 0},
326 {"extern", s_ignore
, 0}, /* We treat all undef as ext. */
327 {"appfile", s_app_file
, 1},
328 {"appline", s_app_line
, 0},
330 {"file", s_app_file
, 0},
332 {"float", float_cons
, 'f'},
333 {"format", s_ignore
, 0},
335 {"global", s_globl
, 0},
336 {"globl", s_globl
, 0},
338 {"if", s_if
, (int) O_ne
},
340 {"ifdef", s_ifdef
, 0},
341 {"ifeq", s_if
, (int) O_eq
},
342 {"ifeqs", s_ifeqs
, 0},
343 {"ifge", s_if
, (int) O_ge
},
344 {"ifgt", s_if
, (int) O_gt
},
345 {"ifle", s_if
, (int) O_le
},
346 {"iflt", s_if
, (int) O_lt
},
348 {"ifndef", s_ifdef
, 1},
349 {"ifne", s_if
, (int) O_ne
},
350 {"ifnes", s_ifeqs
, 1},
351 {"ifnotdef", s_ifdef
, 1},
352 {"incbin", s_incbin
, 0},
353 {"include", s_include
, 0},
359 {"lcomm", s_lcomm
, 0},
360 {"lflags", listing_flags
, 0}, /* Listing flags. */
361 {"linkonce", s_linkonce
, 0},
362 {"list", listing_list
, 1}, /* Turn listing on. */
363 {"llen", listing_psize
, 1},
366 {"macro", s_macro
, 0},
367 {"mexit", s_mexit
, 0},
369 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
370 {"name", s_ignore
, 0},
371 {"noformat", s_ignore
, 0},
372 {"nolist", listing_list
, 0}, /* Turn listing off. */
373 {"nopage", listing_nopage
, 0},
375 {"offset", s_struct
, 0},
377 {"p2align", s_align_ptwo
, 0},
378 {"p2alignw", s_align_ptwo
, -2},
379 {"p2alignl", s_align_ptwo
, -4},
380 {"page", listing_eject
, 0},
381 {"plen", listing_psize
, 0},
382 {"print", s_print
, 0},
383 {"psize", listing_psize
, 0}, /* Set paper size. */
384 {"purgem", s_purgem
, 0},
389 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
394 {"single", float_cons
, 'f'},
396 {"space", s_space
, 0},
397 {"skip", s_space
, 0},
398 {"sleb128", s_leb128
, 1},
399 {"spc", s_ignore
, 0},
400 {"stabd", s_stab
, 'd'},
401 {"stabn", s_stab
, 'n'},
402 {"stabs", s_stab
, 's'},
403 {"string", stringer
, 1},
404 {"struct", s_struct
, 0},
408 /* This is for gcc to use. It's only just been added (2/94), so gcc
409 won't be able to use it for a while -- probably a year or more.
410 But once this has been released, check with gcc maintainers
411 before deleting it or even changing the spelling. */
412 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
413 /* If we're folding case -- done for some targets, not necessarily
414 all -- the above string in an input file will be converted to
415 this one. Match it either way... */
416 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
418 {"title", listing_title
, 0}, /* Listing title. */
419 {"ttl", listing_title
, 0},
421 {"uleb128", s_leb128
, 0},
425 {"xdef", s_globl
, 0},
426 {"xref", s_ignore
, 0},
427 {"xstabs", s_xstab
, 's'},
429 {"zero", s_space
, 0},
430 {NULL
, NULL
, 0} /* End sentinel. */
433 static int pop_override_ok
= 0;
434 static const char *pop_table_name
;
438 const pseudo_typeS
*table
;
441 const pseudo_typeS
*pop
;
442 for (pop
= table
; pop
->poc_name
; pop
++)
444 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
445 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
446 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
451 #ifndef md_pop_insert
452 #define md_pop_insert() pop_insert(md_pseudo_table)
455 #ifndef obj_pop_insert
456 #define obj_pop_insert() pop_insert(obj_pseudo_table)
462 po_hash
= hash_new ();
464 /* Do the target-specific pseudo ops. */
465 pop_table_name
= "md";
468 /* Now object specific. Skip any that were in the target table. */
469 pop_table_name
= "obj";
473 /* Now portable ones. Skip any that we've seen already. */
474 pop_table_name
= "standard";
475 pop_insert (potable
);
478 #define HANDLE_CONDITIONAL_ASSEMBLY() \
479 if (ignore_input ()) \
481 while (!is_end_of_line[(unsigned char) *input_line_pointer++]) \
482 if (input_line_pointer == buffer_limit) \
487 /* This function is used when scrubbing the characters between #APP
490 static char *scrub_string
;
491 static char *scrub_string_end
;
494 scrub_from_string (buf
, buflen
)
500 copy
= scrub_string_end
- scrub_string
;
503 memcpy (buf
, scrub_string
, copy
);
504 scrub_string
+= copy
;
508 /* We read the file, putting things into a web that represents what we
509 have been reading. */
511 read_a_source_file (name
)
515 register char *s
; /* String of symbol, '\0' appended. */
523 buffer
= input_scrub_new_file (name
);
526 listing_newline (NULL
);
527 register_dependency (name
);
529 /* Generate debugging information before we've read anything in to denote
530 this file as the "main" source file and not a subordinate one
531 (e.g. N_SO vs N_SOL in stabs). */
532 generate_file_debug ();
534 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
535 { /* We have another line to parse. */
536 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
537 contin
: /* JF this goto is my fault I admit it.
538 Someone brave please re-write the whole
539 input section here? Pleeze??? */
540 while (input_line_pointer
< buffer_limit
)
542 /* We have more of this buffer to parse. */
544 /* We now have input_line_pointer->1st char of next line.
545 If input_line_pointer [-1] == '\n' then we just
546 scanned another line: so bump line counters. */
547 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
549 #ifdef md_start_line_hook
550 md_start_line_hook ();
552 if (input_line_pointer
[-1] == '\n')
553 bump_line_counters ();
557 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
559 /* Text at the start of a line must be a label, we
560 run down and stick a colon in. */
561 if (is_name_beginner (*input_line_pointer
))
563 char *line_start
= input_line_pointer
;
568 HANDLE_CONDITIONAL_ASSEMBLY ();
570 c
= get_symbol_end ();
572 /* In MRI mode, the EQU and MACRO pseudoops must
573 be handled specially. */
577 char *rest
= input_line_pointer
+ 1;
581 if (*rest
== ' ' || *rest
== '\t')
583 if ((strncasecmp (rest
, "EQU", 3) == 0
584 || strncasecmp (rest
, "SET", 3) == 0)
585 && (rest
[3] == ' ' || rest
[3] == '\t'))
587 input_line_pointer
= rest
+ 3;
589 strncasecmp (rest
, "SET", 3) == 0);
592 if (strncasecmp (rest
, "MACRO", 5) == 0
595 || is_end_of_line
[(unsigned char) rest
[5]]))
599 /* In MRI mode, we need to handle the MACRO
600 pseudo-op specially: we don't want to put the
601 symbol in the symbol table. */
603 #ifdef TC_START_LABEL_WITHOUT_COLON
604 && TC_START_LABEL_WITHOUT_COLON(c
,
608 line_label
= colon (line_start
);
610 line_label
= symbol_create (line_start
,
615 *input_line_pointer
= c
;
617 input_line_pointer
++;
622 /* We are at the begining of a line, or similar place.
623 We expect a well-formed assembler statement.
624 A "symbol-name:" is a statement.
626 Depending on what compiler is used, the order of these tests
627 may vary to catch most common case 1st.
628 Each test is independent of all other tests at the (top) level.
629 PLEASE make a compiler that doesn't use this assembler.
630 It is crufty to waste a compiler's time encoding things for this
631 assembler, which then wastes more time decoding it.
632 (And communicating via (linear) files is silly!
633 If you must pass stuff, please pass a tree!) */
634 if ((c
= *input_line_pointer
++) == '\t'
638 c
= *input_line_pointer
++;
640 know (c
!= ' '); /* No further leading whitespace. */
643 /* If listing is on, and we are expanding a macro, then give
644 the listing code the contents of the expanded line. */
647 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
652 /* Find the end of the current expanded macro line. */
653 for (s
= input_line_pointer
- 1; *s
; ++s
)
654 if (is_end_of_line
[(unsigned char) *s
])
657 /* Copy it for safe keeping. Also give an indication of
658 how much macro nesting is involved at this point. */
659 len
= s
- (input_line_pointer
- 1);
660 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
661 memset (copy
, '>', macro_nest
);
662 copy
[macro_nest
] = ' ';
663 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
- 1, len
);
664 copy
[macro_nest
+ 1 + len
] = '\0';
666 /* Install the line with the listing facility. */
667 listing_newline (copy
);
670 listing_newline (NULL
);
673 /* C is the 1st significant character.
674 Input_line_pointer points after that character. */
675 if (is_name_beginner (c
))
677 /* Want user-defined label or pseudo/opcode. */
678 HANDLE_CONDITIONAL_ASSEMBLY ();
680 s
= --input_line_pointer
;
681 c
= get_symbol_end (); /* name's delimiter. */
683 /* C is character after symbol.
684 That character's place in the input line is now '\0'.
685 S points to the beginning of the symbol.
686 [In case of pseudo-op, s->'.'.]
687 Input_line_pointer->'\0' where c was. */
688 if (TC_START_LABEL (c
, input_line_pointer
))
692 char *rest
= input_line_pointer
+ 1;
694 /* In MRI mode, \tsym: set 0 is permitted. */
698 if (*rest
== ' ' || *rest
== '\t')
701 if ((strncasecmp (rest
, "EQU", 3) == 0
702 || strncasecmp (rest
, "SET", 3) == 0)
703 && (rest
[3] == ' ' || rest
[3] == '\t'))
705 input_line_pointer
= rest
+ 3;
711 line_label
= colon (s
); /* User-defined label. */
712 /* Put ':' back for error messages' sake. */
713 *input_line_pointer
++ = ':';
714 /* Input_line_pointer->after ':'. */
718 || ((c
== ' ' || c
== '\t')
719 && input_line_pointer
[1] == '='
720 #ifdef TC_EQUAL_IN_INSN
721 && !TC_EQUAL_IN_INSN (c
, input_line_pointer
)
726 demand_empty_rest_of_line ();
730 /* Expect pseudo-op or machine instruction. */
733 #ifdef IGNORE_OPCODE_CASE
737 strncpy (original_case_string
, s2
, sizeof (original_case_string
));
738 original_case_string
[sizeof (original_case_string
) - 1] = 0;
742 if (isupper ((unsigned char) *s2
))
748 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
750 /* The MRI assembler and the m88k use pseudo-ops
752 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
753 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
758 || (!flag_m68k_mri
&& *s
== '.'))
762 WARNING: c has next char, which may be end-of-line.
763 We lookup the pseudo-op table with s+1 because we
764 already know that the pseudo-op begins with a '.'. */
767 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
769 /* In MRI mode, we may need to insert an
770 automatic alignment directive. What a hack
772 if (mri_pending_align
774 || !((pop
->poc_handler
== cons
775 && pop
->poc_val
== 1)
776 || (pop
->poc_handler
== s_space
777 && pop
->poc_val
== 1)
778 #ifdef tc_conditional_pseudoop
779 || tc_conditional_pseudoop (pop
)
781 || pop
->poc_handler
== s_if
782 || pop
->poc_handler
== s_ifdef
783 || pop
->poc_handler
== s_ifc
784 || pop
->poc_handler
== s_ifeqs
785 || pop
->poc_handler
== s_else
786 || pop
->poc_handler
== s_endif
787 || pop
->poc_handler
== s_globl
788 || pop
->poc_handler
== s_ignore
)))
790 do_align (1, (char *) NULL
, 0, 0);
791 mri_pending_align
= 0;
793 if (line_label
!= NULL
)
795 symbol_set_frag (line_label
, frag_now
);
796 S_SET_VALUE (line_label
, frag_now_fix ());
800 /* Print the error msg now, while we still can. */
803 as_bad (_("Unknown pseudo-op: `%s'"), s
);
804 *input_line_pointer
= c
;
809 /* Put it back for error messages etc. */
810 *input_line_pointer
= c
;
811 /* The following skip of whitespace is compulsory.
812 A well shaped space is sometimes all that separates
813 keyword from operands. */
814 if (c
== ' ' || c
== '\t')
815 input_line_pointer
++;
817 /* Input_line is restored.
818 Input_line_pointer->1st non-blank char
819 after pseudo-operation. */
820 (*pop
->poc_handler
) (pop
->poc_val
);
822 /* If that was .end, just get out now. */
823 if (pop
->poc_handler
== s_end
)
829 #ifdef QUOTES_IN_INSN
833 /* WARNING: c has char, which may be end-of-line. */
834 /* Also: input_line_pointer->`\0` where c was. */
835 *input_line_pointer
= c
;
836 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
838 #ifdef TC_EOL_IN_INSN
839 || TC_EOL_IN_INSN (input_line_pointer
)
843 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
845 #ifdef QUOTES_IN_INSN
848 else if (*input_line_pointer
== '"')
850 else if (*input_line_pointer
== '\\')
853 input_line_pointer
++;
856 c
= *input_line_pointer
;
857 *input_line_pointer
= '\0';
859 generate_lineno_debug ();
867 if (check_macro (s
, &out
, '\0', &err
, ¯o
))
871 *input_line_pointer
++ = c
;
872 input_scrub_include_sb (&out
,
873 input_line_pointer
, 1);
876 input_scrub_next_buffer (&input_line_pointer
);
878 md_macro_info (macro
);
884 if (mri_pending_align
)
886 do_align (1, (char *) NULL
, 0, 0);
887 mri_pending_align
= 0;
888 if (line_label
!= NULL
)
890 symbol_set_frag (line_label
, frag_now
);
891 S_SET_VALUE (line_label
, frag_now_fix ());
895 md_assemble (s
); /* Assemble 1 instruction. */
897 *input_line_pointer
++ = c
;
899 /* We resume loop AFTER the end-of-line from
906 /* Empty statement? */
907 if (is_end_of_line
[(unsigned char) c
])
910 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
911 && isdigit ((unsigned char) c
))
913 /* local label ("4:") */
914 char *backup
= input_line_pointer
;
916 HANDLE_CONDITIONAL_ASSEMBLY ();
920 /* Read the whole number. */
921 while (isdigit ((unsigned char) *input_line_pointer
))
923 temp
= (temp
* 10) + *input_line_pointer
- '0';
924 ++input_line_pointer
;
927 if (LOCAL_LABELS_DOLLAR
928 && *input_line_pointer
== '$'
929 && *(input_line_pointer
+ 1) == ':')
931 input_line_pointer
+= 2;
933 if (dollar_label_defined (temp
))
935 as_fatal (_("label \"%d$\" redefined"), temp
);
938 define_dollar_label (temp
);
939 colon (dollar_label_name (temp
, 0));
944 && *input_line_pointer
++ == ':')
946 fb_label_instance_inc (temp
);
947 colon (fb_label_name (temp
, 0));
951 input_line_pointer
= backup
;
952 } /* local label ("4:") */
954 if (c
&& strchr (line_comment_chars
, c
))
955 { /* Its a comment. Better say APP or NO_APP. */
959 unsigned int new_length
;
962 bump_line_counters ();
963 s
= input_line_pointer
;
964 if (strncmp (s
, "APP\n", 4))
965 continue; /* We ignore it */
968 ends
= strstr (s
, "#NO_APP\n");
972 unsigned int tmp_len
;
975 /* The end of the #APP wasn't in this buffer. We
976 keep reading in buffers until we find the #NO_APP
977 that goes with this #APP There is one. The specs
979 tmp_len
= buffer_limit
- s
;
980 tmp_buf
= xmalloc (tmp_len
+ 1);
981 memcpy (tmp_buf
, s
, tmp_len
);
984 new_tmp
= input_scrub_next_buffer (&buffer
);
988 buffer_limit
= new_tmp
;
989 input_line_pointer
= buffer
;
990 ends
= strstr (buffer
, "#NO_APP\n");
994 num
= buffer_limit
- buffer
;
996 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
997 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
1002 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1010 input_line_pointer
= ends
+ 8;
1014 scrub_string_end
= ends
;
1016 new_length
= ends
- s
;
1017 new_buf
= (char *) xmalloc (new_length
);
1024 space
= (new_buf
+ new_length
) - new_tmp
;
1025 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1033 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1034 new_tmp
= new_buf
+ new_length
;
1040 old_buffer
= buffer
;
1041 old_input
= input_line_pointer
;
1042 old_limit
= buffer_limit
;
1044 input_line_pointer
= new_buf
;
1045 buffer_limit
= new_tmp
;
1050 HANDLE_CONDITIONAL_ASSEMBLY ();
1052 #ifdef tc_unrecognized_line
1053 if (tc_unrecognized_line (c
))
1056 /* as_warn (_("Junk character %d."),c); Now done by ignore_rest. */
1057 input_line_pointer
--; /* Report unknown char as ignored. */
1058 ignore_rest_of_line ();
1061 #ifdef md_after_pass_hook
1062 md_after_pass_hook ();
1068 bump_line_counters ();
1071 buffer
= old_buffer
;
1072 input_line_pointer
= old_input
;
1073 buffer_limit
= old_limit
;
1085 /* Close the input file. */
1086 input_scrub_close ();
1087 #ifdef WARN_COMMENTS
1089 if (warn_comment
&& found_comment
)
1090 as_warn_where (found_comment_file
, found_comment
,
1091 "first comment found here");
1096 /* For most MRI pseudo-ops, the line actually ends at the first
1097 nonquoted space. This function looks for that point, stuffs a null
1098 in, and sets *STOPCP to the character that used to be there, and
1099 returns the location.
1101 Until I hear otherwise, I am going to assume that this is only true
1102 for the m68k MRI assembler. */
1105 mri_comment_field (stopcp
)
1112 know (flag_m68k_mri
);
1114 for (s
= input_line_pointer
;
1115 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1123 for (s
= input_line_pointer
;
1124 !is_end_of_line
[(unsigned char) *s
];
1134 /* Skip to the end of an MRI comment field. */
1137 mri_comment_end (stop
, stopc
)
1143 input_line_pointer
= stop
;
1145 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1146 ++input_line_pointer
;
1151 int ignore ATTRIBUTE_UNUSED
;
1153 as_fatal (_(".abort detected. Abandoning ship."));
1156 /* Guts of .align directive. N is the power of two to which to align.
1157 FILL may be NULL, or it may point to the bytes of the fill pattern.
1158 LEN is the length of whatever FILL points to, if anything. MAX is
1159 the maximum number of characters to skip when doing the alignment,
1160 or 0 if there is no maximum. */
1163 do_align (n
, fill
, len
, max
)
1170 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1173 /* Only make a frag if we HAVE to... */
1174 if (n
!= 0 && !need_pass_2
)
1178 if (subseg_text_p (now_seg
))
1179 frag_align_code (n
, max
);
1181 frag_align (n
, 0, max
);
1184 frag_align (n
, *fill
, max
);
1186 frag_align_pattern (n
, fill
, len
, max
);
1190 just_record_alignment
:
1193 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1196 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1197 (in bytes). A negative ARG is the negative of the length of the
1198 fill pattern. BYTES_P is non-zero if the alignment value should be
1199 interpreted as the byte boundary, rather than the power of 2. */
1202 s_align (arg
, bytes_p
)
1206 register unsigned int align
;
1214 stop
= mri_comment_field (&stopc
);
1216 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1221 align
= arg
; /* Default value from pseudo-op table. */
1225 align
= get_absolute_expression ();
1231 /* Convert to a power of 2. */
1236 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1239 as_bad (_("Alignment not a power of 2"));
1248 as_bad (_("Alignment too large: %u assumed"), align
);
1251 if (*input_line_pointer
!= ',')
1258 ++input_line_pointer
;
1259 if (*input_line_pointer
== ',')
1263 fill
= get_absolute_expression ();
1268 if (*input_line_pointer
!= ',')
1272 ++input_line_pointer
;
1273 max
= get_absolute_expression ();
1280 as_warn (_("expected fill pattern missing"));
1281 do_align (align
, (char *) NULL
, 0, max
);
1296 do_align (align
, &fill_char
, fill_len
, max
);
1302 if ((size_t) fill_len
> sizeof ab
)
1304 md_number_to_chars (ab
, fill
, fill_len
);
1305 do_align (align
, ab
, fill_len
, max
);
1309 demand_empty_rest_of_line ();
1312 mri_comment_end (stop
, stopc
);
1315 /* Handle the .align pseudo-op on machines where ".align 4" means
1316 align to a 4 byte boundary. */
1325 /* Handle the .align pseudo-op on machines where ".align 4" means align
1326 to a 2**4 boundary. */
1337 int ignore ATTRIBUTE_UNUSED
;
1339 register char *name
;
1343 register symbolS
*symbolP
;
1348 stop
= mri_comment_field (&stopc
);
1350 name
= input_line_pointer
;
1351 c
= get_symbol_end ();
1352 /* Just after name is now '\0'. */
1353 p
= input_line_pointer
;
1357 if (*input_line_pointer
!= ',')
1359 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1360 ignore_rest_of_line ();
1362 mri_comment_end (stop
, stopc
);
1366 input_line_pointer
++; /* skip ',' */
1368 if ((temp
= get_absolute_expression ()) < 0)
1370 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
1371 ignore_rest_of_line ();
1373 mri_comment_end (stop
, stopc
);
1378 symbolP
= symbol_find_or_make (name
);
1381 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1383 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1384 S_GET_NAME (symbolP
));
1385 ignore_rest_of_line ();
1387 mri_comment_end (stop
, stopc
);
1391 if (S_GET_VALUE (symbolP
))
1393 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1394 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
1395 S_GET_NAME (symbolP
),
1396 (long) S_GET_VALUE (symbolP
),
1401 S_SET_VALUE (symbolP
, (valueT
) temp
);
1402 S_SET_EXTERNAL (symbolP
);
1406 extern int flag_one
;
1407 if (!temp
|| !flag_one
)
1408 S_GET_OTHER(symbolP
) = const_flag
;
1410 #endif /* not OBJ_VMS */
1411 know (symbolP
->sy_frag
== &zero_address_frag
);
1413 demand_empty_rest_of_line ();
1416 mri_comment_end (stop
, stopc
);
1419 /* The MRI COMMON pseudo-op. We handle this by creating a common
1420 symbol with the appropriate name. We make s_space do the right
1421 thing by increasing the size. */
1424 s_mri_common (small
)
1425 int small ATTRIBUTE_UNUSED
;
1441 stop
= mri_comment_field (&stopc
);
1445 name
= input_line_pointer
;
1446 if (!isdigit ((unsigned char) *name
))
1447 c
= get_symbol_end ();
1452 ++input_line_pointer
;
1454 while (isdigit ((unsigned char) *input_line_pointer
));
1456 c
= *input_line_pointer
;
1457 *input_line_pointer
= '\0';
1459 if (line_label
!= NULL
)
1461 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1462 + (input_line_pointer
- name
)
1464 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1469 sym
= symbol_find_or_make (name
);
1470 *input_line_pointer
= c
;
1474 if (*input_line_pointer
!= ',')
1478 ++input_line_pointer
;
1479 align
= get_absolute_expression ();
1482 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1484 as_bad (_("attempt to re-define symbol `%s'"), S_GET_NAME (sym
));
1485 ignore_rest_of_line ();
1486 mri_comment_end (stop
, stopc
);
1490 S_SET_EXTERNAL (sym
);
1491 mri_common_symbol
= sym
;
1495 S_SET_ALIGN (sym
, align
);
1498 if (line_label
!= NULL
)
1501 exp
.X_op
= O_symbol
;
1502 exp
.X_add_symbol
= sym
;
1503 exp
.X_add_number
= 0;
1504 symbol_set_value_expression (line_label
, &exp
);
1505 symbol_set_frag (line_label
, &zero_address_frag
);
1506 S_SET_SEGMENT (line_label
, expr_section
);
1509 /* FIXME: We just ignore the small argument, which distinguishes
1510 COMMON and COMMON.S. I don't know what we can do about it. */
1512 /* Ignore the type and hptype. */
1513 if (*input_line_pointer
== ',')
1514 input_line_pointer
+= 2;
1515 if (*input_line_pointer
== ',')
1516 input_line_pointer
+= 2;
1518 demand_empty_rest_of_line ();
1520 mri_comment_end (stop
, stopc
);
1525 int ignore ATTRIBUTE_UNUSED
;
1530 temp
= get_absolute_expression ();
1531 if (flag_readonly_data_in_text
)
1533 section
= text_section
;
1537 section
= data_section
;
1539 subseg_set (section
, (subsegT
) temp
);
1544 demand_empty_rest_of_line ();
1547 /* Handle the .appfile pseudo-op. This is automatically generated by
1548 do_scrub_chars when a preprocessor # line comment is seen with a
1549 file name. This default definition may be overridden by the object
1550 or CPU specific pseudo-ops. This function is also the default
1551 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1555 s_app_file (appfile
)
1561 /* Some assemblers tolerate immediately following '"'. */
1562 if ((s
= demand_copy_string (&length
)) != 0)
1564 /* If this is a fake .appfile, a fake newline was inserted into
1565 the buffer. Passing -2 to new_logical_line tells it to
1568 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1570 /* In MRI mode, the preprocessor may have inserted an extraneous
1573 && *input_line_pointer
== '\''
1574 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1575 ++input_line_pointer
;
1577 demand_empty_rest_of_line ();
1582 listing_source_file (s
);
1584 register_dependency (s
);
1592 /* Handle the .appline pseudo-op. This is automatically generated by
1593 do_scrub_chars when a preprocessor # line comment is seen. This
1594 default definition may be overridden by the object or CPU specific
1599 int ignore ATTRIBUTE_UNUSED
;
1603 /* The given number is that of the next line. */
1604 l
= get_absolute_expression () - 1;
1606 /* Some of the back ends can't deal with non-positive line numbers.
1607 Besides, it's silly. */
1608 as_warn (_("Line numbers must be positive; line number %d rejected."),
1612 new_logical_line ((char *) NULL
, l
);
1615 listing_source_line (l
);
1618 demand_empty_rest_of_line ();
1621 /* Handle the .end pseudo-op. Actually, the real work is done in
1622 read_a_source_file. */
1626 int ignore ATTRIBUTE_UNUSED
;
1630 /* The MRI assembler permits the start symbol to follow .end,
1631 but we don't support that. */
1633 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1634 && *input_line_pointer
!= '*'
1635 && *input_line_pointer
!= '!')
1636 as_warn (_("start address not supported"));
1640 /* Handle the .err pseudo-op. */
1644 int ignore ATTRIBUTE_UNUSED
;
1646 as_bad (_(".err encountered"));
1647 demand_empty_rest_of_line ();
1650 /* Handle the MRI fail pseudo-op. */
1654 int ignore ATTRIBUTE_UNUSED
;
1661 stop
= mri_comment_field (&stopc
);
1663 temp
= get_absolute_expression ();
1665 as_warn (_(".fail %ld encountered"), (long) temp
);
1667 as_bad (_(".fail %ld encountered"), (long) temp
);
1669 demand_empty_rest_of_line ();
1672 mri_comment_end (stop
, stopc
);
1677 int ignore ATTRIBUTE_UNUSED
;
1679 expressionS rep_exp
;
1681 register long fill
= 0;
1684 #ifdef md_flush_pending_output
1685 md_flush_pending_output ();
1688 get_known_segmented_expression (&rep_exp
);
1689 if (*input_line_pointer
== ',')
1691 input_line_pointer
++;
1692 size
= get_absolute_expression ();
1693 if (*input_line_pointer
== ',')
1695 input_line_pointer
++;
1696 fill
= get_absolute_expression ();
1700 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1701 #define BSD_FILL_SIZE_CROCK_8 (8)
1702 if (size
> BSD_FILL_SIZE_CROCK_8
)
1704 as_warn (_(".fill size clamped to %d."), BSD_FILL_SIZE_CROCK_8
);
1705 size
= BSD_FILL_SIZE_CROCK_8
;
1709 as_warn (_("Size negative: .fill ignored."));
1712 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1714 if (rep_exp
.X_add_number
< 0)
1715 as_warn (_("Repeat < 0, .fill ignored"));
1719 if (size
&& !need_pass_2
)
1721 if (rep_exp
.X_op
== O_constant
)
1723 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1724 (relax_substateT
) 0, (symbolS
*) 0,
1725 (offsetT
) rep_exp
.X_add_number
,
1730 /* We don't have a constant repeat count, so we can't use
1731 rs_fill. We can get the same results out of rs_space,
1732 but its argument is in bytes, so we must multiply the
1733 repeat count by size. */
1736 rep_sym
= make_expr_symbol (&rep_exp
);
1739 expressionS size_exp
;
1740 size_exp
.X_op
= O_constant
;
1741 size_exp
.X_add_number
= size
;
1743 rep_exp
.X_op
= O_multiply
;
1744 rep_exp
.X_add_symbol
= rep_sym
;
1745 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1746 rep_exp
.X_add_number
= 0;
1747 rep_sym
= make_expr_symbol (&rep_exp
);
1750 p
= frag_var (rs_space
, (int) size
, (int) size
,
1751 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1754 memset (p
, 0, (unsigned int) size
);
1756 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1757 flavoured AS. The following bizarre behaviour is to be
1758 compatible with above. I guess they tried to take up to 8
1759 bytes from a 4-byte expression and they forgot to sign
1761 #define BSD_FILL_SIZE_CROCK_4 (4)
1762 md_number_to_chars (p
, (valueT
) fill
,
1763 (size
> BSD_FILL_SIZE_CROCK_4
1764 ? BSD_FILL_SIZE_CROCK_4
1766 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1767 but emits no error message because it seems a legal thing to do.
1768 It is a degenerate case of .fill but could be emitted by a
1771 demand_empty_rest_of_line ();
1776 int ignore ATTRIBUTE_UNUSED
;
1785 stop
= mri_comment_field (&stopc
);
1789 name
= input_line_pointer
;
1790 c
= get_symbol_end ();
1791 symbolP
= symbol_find_or_make (name
);
1792 S_SET_EXTERNAL (symbolP
);
1794 *input_line_pointer
= c
;
1796 c
= *input_line_pointer
;
1799 input_line_pointer
++;
1801 if (*input_line_pointer
== '\n')
1807 demand_empty_rest_of_line ();
1810 mri_comment_end (stop
, stopc
);
1813 /* Handle the MRI IRP and IRPC pseudo-ops. */
1825 as_where (&file
, &line
);
1828 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1829 sb_add_char (&s
, *input_line_pointer
++);
1833 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1835 as_bad_where (file
, line
, "%s", err
);
1839 input_scrub_include_sb (&out
, input_line_pointer
, 1);
1841 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1844 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1845 the section to only be linked once. However, this is not supported
1846 by most object file formats. This takes an optional argument,
1847 which is what to do about duplicates. */
1851 int ignore ATTRIBUTE_UNUSED
;
1853 enum linkonce_type type
;
1857 type
= LINKONCE_DISCARD
;
1859 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1864 s
= input_line_pointer
;
1865 c
= get_symbol_end ();
1866 if (strcasecmp (s
, "discard") == 0)
1867 type
= LINKONCE_DISCARD
;
1868 else if (strcasecmp (s
, "one_only") == 0)
1869 type
= LINKONCE_ONE_ONLY
;
1870 else if (strcasecmp (s
, "same_size") == 0)
1871 type
= LINKONCE_SAME_SIZE
;
1872 else if (strcasecmp (s
, "same_contents") == 0)
1873 type
= LINKONCE_SAME_CONTENTS
;
1875 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1877 *input_line_pointer
= c
;
1880 #ifdef obj_handle_link_once
1881 obj_handle_link_once (type
);
1882 #else /* ! defined (obj_handle_link_once) */
1883 #ifdef BFD_ASSEMBLER
1887 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1888 as_warn (_(".linkonce is not supported for this object file format"));
1890 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1891 flags
|= SEC_LINK_ONCE
;
1896 case LINKONCE_DISCARD
:
1897 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1899 case LINKONCE_ONE_ONLY
:
1900 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1902 case LINKONCE_SAME_SIZE
:
1903 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1905 case LINKONCE_SAME_CONTENTS
:
1906 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1909 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1910 as_bad (_("bfd_set_section_flags: %s"),
1911 bfd_errmsg (bfd_get_error ()));
1913 #else /* ! defined (BFD_ASSEMBLER) */
1914 as_warn (_(".linkonce is not supported for this object file format"));
1915 #endif /* ! defined (BFD_ASSEMBLER) */
1916 #endif /* ! defined (obj_handle_link_once) */
1918 demand_empty_rest_of_line ();
1922 s_lcomm_internal (needs_align
, bytes_p
)
1923 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1924 (alignment); 0 if it was an ".lcomm" (2 args only). */
1926 /* 1 if the alignment value should be interpreted as the byte boundary,
1927 rather than the power of 2. */
1930 register char *name
;
1934 register symbolS
*symbolP
;
1935 segT current_seg
= now_seg
;
1936 subsegT current_subseg
= now_subseg
;
1937 const int max_alignment
= 15;
1939 segT bss_seg
= bss_section
;
1941 name
= input_line_pointer
;
1942 c
= get_symbol_end ();
1943 p
= input_line_pointer
;
1947 /* Accept an optional comma after the name. The comma used to be
1948 required, but Irix 5 cc does not generate it. */
1949 if (*input_line_pointer
== ',')
1951 ++input_line_pointer
;
1955 if (*input_line_pointer
== '\n')
1957 as_bad (_("Missing size expression"));
1961 if ((temp
= get_absolute_expression ()) < 0)
1963 as_warn (_("BSS length (%d.) <0! Ignored."), temp
);
1964 ignore_rest_of_line ();
1968 #if defined (TC_MIPS) || defined (TC_ALPHA)
1969 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1970 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1972 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1973 if (temp
<= bfd_get_gp_size (stdoutput
))
1975 bss_seg
= subseg_new (".sbss", 1);
1976 seg_info (bss_seg
)->bss
= 1;
1977 #ifdef BFD_ASSEMBLER
1978 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1979 as_warn (_("error setting flags for \".sbss\": %s"),
1980 bfd_errmsg (bfd_get_error ()));
1988 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
1990 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
1992 record_alignment (bss_seg
, align
);
2000 if (*input_line_pointer
!= ',')
2002 as_bad (_("Expected comma after size"));
2003 ignore_rest_of_line ();
2007 input_line_pointer
++;
2010 if (*input_line_pointer
== '\n')
2012 as_bad (_("Missing alignment"));
2016 align
= get_absolute_expression ();
2020 /* Convert to a power of 2. */
2025 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2028 as_bad (_("Alignment not a power of 2"));
2033 if (align
> max_alignment
)
2035 align
= max_alignment
;
2036 as_warn (_("Alignment too large: %d. assumed."), align
);
2041 as_warn (_("Alignment negative. 0 assumed."));
2044 record_alignment (bss_seg
, align
);
2048 /* Assume some objects may require alignment on some systems. */
2049 #if defined (TC_ALPHA) && ! defined (VMS)
2052 align
= ffs (temp
) - 1;
2053 if (temp
% (1 << align
))
2060 symbolP
= symbol_find_or_make (name
);
2064 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2065 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2066 #ifdef BFD_ASSEMBLER
2067 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2068 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2070 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2073 (S_GET_SEGMENT (symbolP
) == bss_seg
2074 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2078 subseg_set (bss_seg
, 1);
2081 frag_align (align
, 0, 0);
2083 /* Detach from old frag. */
2084 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2085 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2087 symbol_set_frag (symbolP
, frag_now
);
2088 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2089 (offsetT
) temp
, (char *) 0);
2092 S_SET_SEGMENT (symbolP
, bss_seg
);
2095 /* The symbol may already have been created with a preceding
2096 ".globl" directive -- be careful not to step on storage class
2097 in that case. Otherwise, set it to static. */
2098 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2100 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2102 #endif /* OBJ_COFF */
2105 S_SET_SIZE (symbolP
, temp
);
2109 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
2110 S_GET_NAME (symbolP
));
2112 subseg_set (current_seg
, current_subseg
);
2114 demand_empty_rest_of_line ();
2118 s_lcomm (needs_align
)
2121 s_lcomm_internal (needs_align
, 0);
2125 s_lcomm_bytes (needs_align
)
2128 s_lcomm_internal (needs_align
, 1);
2133 int ignore ATTRIBUTE_UNUSED
;
2135 register char *name
;
2139 register symbolS
*symbolP
;
2141 /* We permit ANY defined expression: BSD4.2 demands constants. */
2142 name
= input_line_pointer
;
2143 c
= get_symbol_end ();
2144 p
= input_line_pointer
;
2148 if (*input_line_pointer
!= ',')
2151 as_bad (_("Expected comma after name \"%s\""), name
);
2153 ignore_rest_of_line ();
2157 input_line_pointer
++;
2160 if (exp
.X_op
!= O_constant
2161 && exp
.X_op
!= O_register
)
2163 as_bad (_("bad expression"));
2164 ignore_rest_of_line ();
2169 symbolP
= symbol_find_or_make (name
);
2171 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2172 symbolP->sy_desc == 0) out of this test because coff doesn't have
2173 those fields, and I can't see when they'd ever be tripped. I
2174 don't think I understand why they were here so I may have
2175 introduced a bug. As recently as 1.37 didn't have this test
2176 anyway. xoxorich. */
2178 if (S_GET_SEGMENT (symbolP
) == undefined_section
2179 && S_GET_VALUE (symbolP
) == 0)
2181 /* The name might be an undefined .global symbol; be sure to
2182 keep the "external" bit. */
2183 S_SET_SEGMENT (symbolP
,
2184 (exp
.X_op
== O_constant
2187 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2191 as_bad (_("Symbol %s already defined"), name
);
2195 demand_empty_rest_of_line ();
2198 /* Read a line into an sb. */
2204 char quote1
, quote2
, inquote
;
2206 if (input_line_pointer
[-1] == '\n')
2207 bump_line_counters ();
2209 if (input_line_pointer
>= buffer_limit
)
2211 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2212 if (buffer_limit
== 0)
2216 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2217 code needs to be changed. */
2226 #ifdef LEX_IS_STRINGQUOTE
2232 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2233 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2235 if (inquote
== *input_line_pointer
)
2237 else if (inquote
== '\0')
2239 if (*input_line_pointer
== quote1
)
2241 else if (*input_line_pointer
== quote2
)
2245 sb_add_char (line
, *input_line_pointer
++);
2248 while (input_line_pointer
< buffer_limit
2249 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2251 if (input_line_pointer
[-1] == '\n')
2252 bump_line_counters ();
2253 ++input_line_pointer
;
2259 /* Define a macro. This is an interface to macro.c, which is shared
2260 between gas and gasp. */
2264 int ignore ATTRIBUTE_UNUSED
;
2273 as_where (&file
, &line
);
2276 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2277 sb_add_char (&s
, *input_line_pointer
++);
2280 if (line_label
!= NULL
)
2281 sb_add_string (&label
, S_GET_NAME (line_label
));
2283 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2285 as_bad_where (file
, line
, "%s", err
);
2288 if (line_label
!= NULL
)
2290 S_SET_SEGMENT (line_label
, undefined_section
);
2291 S_SET_VALUE (line_label
, 0);
2292 symbol_set_frag (line_label
, &zero_address_frag
);
2295 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2296 && hash_find (po_hash
, name
) != NULL
)
2299 && hash_find (po_hash
, name
+ 1) != NULL
))
2300 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2307 /* Handle the .mexit pseudo-op, which immediately exits a macro
2312 int ignore ATTRIBUTE_UNUSED
;
2314 cond_exit_macro (macro_nest
);
2315 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2318 /* Switch in and out of MRI mode. */
2322 int ignore ATTRIBUTE_UNUSED
;
2326 on
= get_absolute_expression ();
2327 old_flag
= flag_mri
;
2345 /* Operator precedence changes in m68k MRI mode, so we need to
2346 update the operator rankings. */
2347 expr_set_precedence ();
2349 #ifdef MRI_MODE_CHANGE
2351 MRI_MODE_CHANGE (on
);
2354 demand_empty_rest_of_line ();
2357 /* Handle changing the location counter. */
2360 do_org (segment
, exp
, fill
)
2365 if (segment
!= now_seg
&& segment
!= absolute_section
)
2366 as_bad (_("invalid segment \"%s\"; segment \"%s\" assumed"),
2367 segment_name (segment
), segment_name (now_seg
));
2369 if (now_seg
== absolute_section
)
2372 as_warn (_("ignoring fill value in absolute section"));
2373 if (exp
->X_op
!= O_constant
)
2375 as_bad (_("only constant offsets supported in absolute section"));
2376 exp
->X_add_number
= 0;
2378 abs_section_offset
= exp
->X_add_number
;
2383 symbolS
*sym
= exp
->X_add_symbol
;
2384 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2386 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2388 /* Handle complex expressions. */
2389 sym
= make_expr_symbol (exp
);
2393 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2400 int ignore ATTRIBUTE_UNUSED
;
2402 register segT segment
;
2404 register long temp_fill
;
2406 #ifdef md_flush_pending_output
2407 md_flush_pending_output ();
2410 /* The m68k MRI assembler has a different meaning for .org. It
2411 means to create an absolute section at a given address. We can't
2412 support that--use a linker script instead. */
2415 as_bad (_("MRI style ORG pseudo-op not supported"));
2416 ignore_rest_of_line ();
2420 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2421 thing as a sub-segment-relative origin. Any absolute origin is
2422 given a warning, then assumed to be segment-relative. Any
2423 segmented origin expression ("foo+42") had better be in the right
2424 segment or the .org is ignored.
2426 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2427 we never know sub-segment sizes when we are reading code. BSD
2428 will crash trying to emit negative numbers of filler bytes in
2429 certain .orgs. We don't crash, but see as-write for that code.
2431 Don't make frag if need_pass_2==1. */
2432 segment
= get_known_segmented_expression (&exp
);
2433 if (*input_line_pointer
== ',')
2435 input_line_pointer
++;
2436 temp_fill
= get_absolute_expression ();
2442 do_org (segment
, &exp
, temp_fill
);
2444 demand_empty_rest_of_line ();
2447 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2448 called by the obj-format routine which handles section changing
2449 when in MRI mode. It will create a new section, and return it. It
2450 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2451 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2452 flags will be set in the section. */
2456 char *type ATTRIBUTE_UNUSED
;
2466 name
= input_line_pointer
;
2467 if (!isdigit ((unsigned char) *name
))
2468 c
= get_symbol_end ();
2473 ++input_line_pointer
;
2475 while (isdigit ((unsigned char) *input_line_pointer
));
2477 c
= *input_line_pointer
;
2478 *input_line_pointer
= '\0';
2481 name
= xstrdup (name
);
2483 *input_line_pointer
= c
;
2485 seg
= subseg_new (name
, 0);
2487 if (*input_line_pointer
== ',')
2491 ++input_line_pointer
;
2492 align
= get_absolute_expression ();
2493 record_alignment (seg
, align
);
2497 if (*input_line_pointer
== ',')
2499 c
= *++input_line_pointer
;
2500 c
= toupper ((unsigned char) c
);
2501 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2504 as_bad (_("unrecognized section type"));
2505 ++input_line_pointer
;
2507 #ifdef BFD_ASSEMBLER
2511 flags
= SEC_NO_FLAGS
;
2513 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2514 else if (*type
== 'D' || *type
== 'M')
2515 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2516 else if (*type
== 'R')
2517 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2518 if (flags
!= SEC_NO_FLAGS
)
2520 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2521 as_warn (_("error setting flags for \"%s\": %s"),
2522 bfd_section_name (stdoutput
, seg
),
2523 bfd_errmsg (bfd_get_error ()));
2529 /* Ignore the HP type. */
2530 if (*input_line_pointer
== ',')
2531 input_line_pointer
+= 2;
2533 demand_empty_rest_of_line ();
2535 #else /* ! TC_M68K */
2544 name
= input_line_pointer
;
2545 c
= get_symbol_end ();
2547 name
= xstrdup (name
);
2549 *input_line_pointer
= c
;
2551 seg
= subseg_new (name
, 0);
2553 if (*input_line_pointer
!= ',')
2559 ++input_line_pointer
;
2561 sectype
= input_line_pointer
;
2562 c
= get_symbol_end ();
2563 if (*sectype
== '\0')
2565 else if (strcasecmp (sectype
, "text") == 0)
2567 else if (strcasecmp (sectype
, "data") == 0)
2569 else if (strcasecmp (sectype
, "romdata") == 0)
2572 as_warn (_("unrecognized section type `%s'"), sectype
);
2573 *input_line_pointer
= c
;
2576 if (*input_line_pointer
== ',')
2580 ++input_line_pointer
;
2582 seccmd
= input_line_pointer
;
2583 c
= get_symbol_end ();
2584 if (strcasecmp (seccmd
, "absolute") == 0)
2586 as_bad (_("absolute sections are not supported"));
2587 *input_line_pointer
= c
;
2588 ignore_rest_of_line ();
2591 else if (strcasecmp (seccmd
, "align") == 0)
2595 *input_line_pointer
= c
;
2596 align
= get_absolute_expression ();
2597 record_alignment (seg
, align
);
2601 as_warn (_("unrecognized section command `%s'"), seccmd
);
2602 *input_line_pointer
= c
;
2606 demand_empty_rest_of_line ();
2608 #else /* ! TC_I960 */
2609 /* The MRI assembler seems to use different forms of .sect for
2610 different targets. */
2611 as_bad ("MRI mode not supported for this target");
2612 ignore_rest_of_line ();
2613 #endif /* ! TC_I960 */
2614 #endif /* ! TC_M68K */
2617 /* Handle the .print pseudo-op. */
2621 int ignore ATTRIBUTE_UNUSED
;
2626 s
= demand_copy_C_string (&len
);
2628 demand_empty_rest_of_line ();
2631 /* Handle the .purgem pseudo-op. */
2635 int ignore ATTRIBUTE_UNUSED
;
2637 if (is_it_end_of_statement ())
2639 demand_empty_rest_of_line ();
2649 name
= input_line_pointer
;
2650 c
= get_symbol_end ();
2651 delete_macro (name
);
2652 *input_line_pointer
= c
;
2655 while (*input_line_pointer
++ == ',');
2657 --input_line_pointer
;
2658 demand_empty_rest_of_line ();
2661 /* Handle the .rept pseudo-op. */
2665 int ignore ATTRIBUTE_UNUSED
;
2669 count
= get_absolute_expression ();
2671 do_repeat (count
, "REPT", "ENDR");
2674 /* This function provides a generic repeat block implementation. It allows
2675 different directives to be used as the start/end keys. */
2678 do_repeat (count
, start
, end
)
2687 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2689 as_bad (_("%s without %s"), start
, end
);
2695 sb_add_sb (&many
, &one
);
2699 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2701 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2704 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2705 input buffers to skip. Assumes that conditionals preceding the loop end
2706 are properly nested.
2708 This function makes it easier to implement a premature "break" out of the
2709 loop. The EXTRA arg accounts for other buffers we might have inserted,
2710 such as line substitutions. */
2716 cond_exit_macro (macro_nest
);
2717 while (extra
-- >= 0)
2718 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2721 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2722 this is .equiv, and it is an error if the symbol is already
2729 register char *name
;
2730 register char delim
;
2731 register char *end_name
;
2732 register symbolS
*symbolP
;
2734 /* Especial apologies for the random logic:
2735 this just grew, and could be parsed much more simply!
2737 name
= input_line_pointer
;
2738 delim
= get_symbol_end ();
2739 end_name
= input_line_pointer
;
2743 if (*input_line_pointer
!= ',')
2746 as_bad (_("Expected comma after name \"%s\""), name
);
2748 ignore_rest_of_line ();
2752 input_line_pointer
++;
2755 if (name
[0] == '.' && name
[1] == '\0')
2757 /* Turn '. = mumble' into a .org mumble. */
2758 register segT segment
;
2761 segment
= get_known_segmented_expression (&exp
);
2764 do_org (segment
, &exp
, 0);
2770 if ((symbolP
= symbol_find (name
)) == NULL
2771 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2774 /* When doing symbol listings, play games with dummy fragments living
2775 outside the normal fragment chain to record the file and line info
2777 if (listing
& LISTING_SYMBOLS
)
2779 extern struct list_info_struct
*listing_tail
;
2780 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2781 memset (dummy_frag
, 0, sizeof (fragS
));
2782 dummy_frag
->fr_type
= rs_fill
;
2783 dummy_frag
->line
= listing_tail
;
2784 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2785 dummy_frag
->fr_symbol
= symbolP
;
2789 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2792 /* "set" symbols are local unless otherwise specified. */
2793 SF_SET_LOCAL (symbolP
);
2794 #endif /* OBJ_COFF */
2797 symbol_table_insert (symbolP
);
2802 && S_IS_DEFINED (symbolP
)
2803 && S_GET_SEGMENT (symbolP
) != reg_section
)
2804 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
2806 pseudo_set (symbolP
);
2807 demand_empty_rest_of_line ();
2821 #ifdef md_flush_pending_output
2822 md_flush_pending_output ();
2826 stop
= mri_comment_field (&stopc
);
2828 /* In m68k MRI mode, we need to align to a word boundary, unless
2830 if (flag_m68k_mri
&& mult
> 1)
2832 if (now_seg
== absolute_section
)
2834 abs_section_offset
+= abs_section_offset
& 1;
2835 if (line_label
!= NULL
)
2836 S_SET_VALUE (line_label
, abs_section_offset
);
2838 else if (mri_common_symbol
!= NULL
)
2842 val
= S_GET_VALUE (mri_common_symbol
);
2845 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2846 if (line_label
!= NULL
)
2848 expressionS
*symexp
;
2850 symexp
= symbol_get_value_expression (line_label
);
2851 know (symexp
->X_op
== O_symbol
);
2852 know (symexp
->X_add_symbol
== mri_common_symbol
);
2853 symexp
->X_add_number
+= 1;
2859 do_align (1, (char *) NULL
, 0, 0);
2860 if (line_label
!= NULL
)
2862 symbol_set_frag (line_label
, frag_now
);
2863 S_SET_VALUE (line_label
, frag_now_fix ());
2873 if (*input_line_pointer
== ',')
2875 ++input_line_pointer
;
2880 val
.X_op
= O_constant
;
2881 val
.X_add_number
= 0;
2884 if (val
.X_op
!= O_constant
2885 || val
.X_add_number
< - 0x80
2886 || val
.X_add_number
> 0xff
2887 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2889 if (exp
.X_op
!= O_constant
)
2890 as_bad (_("Unsupported variable size or fill value"));
2897 bytes
= mult
* exp
.X_add_number
;
2898 for (i
= 0; i
< exp
.X_add_number
; i
++)
2899 emit_expr (&val
, mult
);
2904 if (exp
.X_op
== O_constant
)
2908 repeat
= exp
.X_add_number
;
2915 as_warn (_(".space repeat count is zero, ignored"));
2916 else if (repeat
< 0)
2917 as_warn (_(".space repeat count is negative, ignored"));
2921 /* If we are in the absolute section, just bump the offset. */
2922 if (now_seg
== absolute_section
)
2924 abs_section_offset
+= repeat
;
2928 /* If we are secretly in an MRI common section, then
2929 creating space just increases the size of the common
2931 if (mri_common_symbol
!= NULL
)
2933 S_SET_VALUE (mri_common_symbol
,
2934 S_GET_VALUE (mri_common_symbol
) + repeat
);
2939 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2940 (offsetT
) repeat
, (char *) 0);
2944 if (now_seg
== absolute_section
)
2946 as_bad (_("space allocation too complex in absolute section"));
2947 subseg_set (text_section
, 0);
2950 if (mri_common_symbol
!= NULL
)
2952 as_bad (_("space allocation too complex in common section"));
2953 mri_common_symbol
= NULL
;
2957 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2958 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2962 *p
= val
.X_add_number
;
2967 /* In MRI mode, after an odd number of bytes, we must align to an
2968 even word boundary, unless the next instruction is a dc.b, ds.b
2970 if (flag_mri
&& (bytes
& 1) != 0)
2971 mri_pending_align
= 1;
2973 demand_empty_rest_of_line ();
2976 mri_comment_end (stop
, stopc
);
2979 /* This is like s_space, but the value is a floating point number with
2980 the given precision. This is for the MRI dcb.s pseudo-op and
2984 s_float_space (float_type
)
2989 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2994 stop
= mri_comment_field (&stopc
);
2996 count
= get_absolute_expression ();
2999 if (*input_line_pointer
!= ',')
3001 as_bad (_("missing value"));
3002 ignore_rest_of_line ();
3004 mri_comment_end (stop
, stopc
);
3008 ++input_line_pointer
;
3012 /* Skip any 0{letter} that may be present. Don't even check if the
3013 * letter is legal. */
3014 if (input_line_pointer
[0] == '0'
3015 && isalpha ((unsigned char) input_line_pointer
[1]))
3016 input_line_pointer
+= 2;
3018 /* Accept :xxxx, where the x's are hex digits, for a floating point
3019 with the exact digits specified. */
3020 if (input_line_pointer
[0] == ':')
3022 flen
= hex_float (float_type
, temp
);
3025 ignore_rest_of_line ();
3027 mri_comment_end (stop
, stopc
);
3035 err
= md_atof (float_type
, temp
, &flen
);
3036 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3040 as_bad (_("Bad floating literal: %s"), err
);
3041 ignore_rest_of_line ();
3043 mri_comment_end (stop
, stopc
);
3048 while (--count
>= 0)
3052 p
= frag_more (flen
);
3053 memcpy (p
, temp
, (unsigned int) flen
);
3056 demand_empty_rest_of_line ();
3059 mri_comment_end (stop
, stopc
);
3062 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3066 int ignore ATTRIBUTE_UNUSED
;
3072 stop
= mri_comment_field (&stopc
);
3073 abs_section_offset
= get_absolute_expression ();
3074 subseg_set (absolute_section
, 0);
3075 demand_empty_rest_of_line ();
3077 mri_comment_end (stop
, stopc
);
3082 int ignore ATTRIBUTE_UNUSED
;
3086 temp
= get_absolute_expression ();
3087 subseg_set (text_section
, (subsegT
) temp
);
3088 demand_empty_rest_of_line ();
3090 const_flag
&= ~IN_DEFAULT_SECTION
;
3095 demand_empty_rest_of_line ()
3098 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3099 input_line_pointer
++;
3101 ignore_rest_of_line ();
3103 /* Return having already swallowed end-of-line. */
3107 ignore_rest_of_line ()
3109 /* For suspect lines: gives warning. */
3110 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3112 if (isprint ((unsigned char) *input_line_pointer
))
3113 as_bad (_("Rest of line ignored. First ignored character is `%c'."),
3114 *input_line_pointer
);
3116 as_bad (_("Rest of line ignored. First ignored character valued 0x%x."),
3117 *input_line_pointer
);
3119 while (input_line_pointer
< buffer_limit
3120 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3121 input_line_pointer
++;
3124 input_line_pointer
++;
3126 /* Return pointing just after end-of-line. */
3127 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3131 discard_rest_of_line ()
3133 while (input_line_pointer
< buffer_limit
3134 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3135 input_line_pointer
++;
3137 input_line_pointer
++;
3139 /* Return pointing just after end-of-line. */
3140 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3143 /* In: Pointer to a symbol.
3144 Input_line_pointer->expression.
3146 Out: Input_line_pointer->just after any whitespace after expression.
3147 Tried to set symbol to value of expression.
3148 Will change symbols type, value, and frag; */
3151 pseudo_set (symbolP
)
3155 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3157 #endif /* OBJ_AOUT or OBJ_BOUT */
3159 know (symbolP
); /* NULL pointer is logic error. */
3160 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3161 ext
= S_IS_EXTERNAL (symbolP
);
3162 #endif /* OBJ_AOUT or OBJ_BOUT */
3164 (void) expression (&exp
);
3166 if (exp
.X_op
== O_illegal
)
3167 as_bad (_("illegal expression; zero assumed"));
3168 else if (exp
.X_op
== O_absent
)
3169 as_bad (_("missing expression; zero assumed"));
3170 else if (exp
.X_op
== O_big
)
3172 if (exp
.X_add_number
> 0)
3173 as_bad (_("bignum invalid; zero assumed"));
3175 as_bad (_("floating point number invalid; zero assumed"));
3177 else if (exp
.X_op
== O_subtract
3178 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3179 == S_GET_SEGMENT (exp
.X_op_symbol
))
3180 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3181 && (symbol_get_frag (exp
.X_add_symbol
)
3182 == symbol_get_frag (exp
.X_op_symbol
)))
3184 exp
.X_op
= O_constant
;
3185 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3186 - S_GET_VALUE (exp
.X_op_symbol
));
3194 exp
.X_add_number
= 0;
3197 S_SET_SEGMENT (symbolP
, absolute_section
);
3198 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3200 S_SET_EXTERNAL (symbolP
);
3202 S_CLEAR_EXTERNAL (symbolP
);
3203 #endif /* OBJ_AOUT or OBJ_BOUT */
3204 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3205 if (exp
.X_op
!= O_constant
)
3206 symbol_set_frag (symbolP
, &zero_address_frag
);
3210 S_SET_SEGMENT (symbolP
, reg_section
);
3211 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3212 symbol_set_frag (symbolP
, &zero_address_frag
);
3216 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3217 || exp
.X_add_number
!= 0)
3218 symbol_set_value_expression (symbolP
, &exp
);
3219 else if (symbol_section_p (symbolP
))
3220 as_bad ("invalid attempt to set value of section symbol");
3223 symbolS
*s
= exp
.X_add_symbol
;
3225 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3226 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3228 S_SET_EXTERNAL (symbolP
);
3230 S_CLEAR_EXTERNAL (symbolP
);
3231 #endif /* OBJ_AOUT or OBJ_BOUT */
3232 S_SET_VALUE (symbolP
,
3233 exp
.X_add_number
+ S_GET_VALUE (s
));
3234 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3235 copy_symbol_attributes (symbolP
, s
);
3240 /* The value is some complex expression.
3241 FIXME: Should we set the segment to anything? */
3242 symbol_set_value_expression (symbolP
, &exp
);
3249 CONStruct more frag of .bytes, or .words etc.
3250 Should need_pass_2 be 1 then emit no frag(s).
3251 This understands EXPRESSIONS.
3255 This has a split personality. We use expression() to read the
3256 value. We can detect if the value won't fit in a byte or word.
3257 But we can't detect if expression() discarded significant digits
3258 in the case of a long. Not worth the crocks required to fix it. */
3260 /* Select a parser for cons expressions. */
3262 /* Some targets need to parse the expression in various fancy ways.
3263 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3264 (for example, the HPPA does this). Otherwise, you can define
3265 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3266 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3267 are defined, which is the normal case, then only simple expressions
3272 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3275 #ifndef TC_PARSE_CONS_EXPRESSION
3276 #ifdef BITFIELD_CONS_EXPRESSIONS
3277 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3279 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3281 #ifdef REPEAT_CONS_EXPRESSIONS
3282 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3284 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3287 /* If we haven't gotten one yet, just call expression. */
3288 #ifndef TC_PARSE_CONS_EXPRESSION
3289 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3293 /* Worker to do .byte etc statements.
3294 Clobbers input_line_pointer and checks end-of-line. */
3297 cons_worker (nbytes
, rva
)
3298 register int nbytes
; /* 1=.byte, 2=.word, 4=.long. */
3306 #ifdef md_flush_pending_output
3307 md_flush_pending_output ();
3311 stop
= mri_comment_field (&stopc
);
3313 if (is_it_end_of_statement ())
3315 demand_empty_rest_of_line ();
3317 mri_comment_end (stop
, stopc
);
3321 #ifdef md_cons_align
3322 md_cons_align (nbytes
);
3330 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3333 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3337 if (exp
.X_op
== O_symbol
)
3338 exp
.X_op
= O_symbol_rva
;
3340 as_fatal (_("rva without symbol"));
3342 emit_expr (&exp
, (unsigned int) nbytes
);
3345 while (*input_line_pointer
++ == ',');
3347 /* In MRI mode, after an odd number of bytes, we must align to an
3348 even word boundary, unless the next instruction is a dc.b, ds.b
3350 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3351 mri_pending_align
= 1;
3353 input_line_pointer
--; /* Put terminator back into stream. */
3355 demand_empty_rest_of_line ();
3358 mri_comment_end (stop
, stopc
);
3365 cons_worker (size
, 0);
3372 cons_worker (size
, 1);
3375 /* Put the contents of expression EXP into the object file using
3376 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3379 emit_expr (exp
, nbytes
)
3381 unsigned int nbytes
;
3385 valueT extra_digit
= 0;
3387 /* Don't do anything if we are going to make another pass. */
3393 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3394 appear as a four byte positive constant in the .line section,
3395 followed by a 2 byte 0xffff. Look for that case here. */
3397 static int dwarf_line
= -1;
3399 if (strcmp (segment_name (now_seg
), ".line") != 0)
3401 else if (dwarf_line
>= 0
3403 && exp
->X_op
== O_constant
3404 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3405 listing_source_line ((unsigned int) dwarf_line
);
3406 else if (nbytes
== 4
3407 && exp
->X_op
== O_constant
3408 && exp
->X_add_number
>= 0)
3409 dwarf_line
= exp
->X_add_number
;
3414 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3415 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3416 AT_sibling (0x12) followed by a four byte address of the sibling
3417 followed by a 2 byte AT_name (0x38) followed by the name of the
3418 file. We look for that case here. */
3420 static int dwarf_file
= 0;
3422 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3424 else if (dwarf_file
== 0
3426 && exp
->X_op
== O_constant
3427 && exp
->X_add_number
== 0x11)
3429 else if (dwarf_file
== 1
3431 && exp
->X_op
== O_constant
3432 && exp
->X_add_number
== 0x12)
3434 else if (dwarf_file
== 2
3437 else if (dwarf_file
== 3
3439 && exp
->X_op
== O_constant
3440 && exp
->X_add_number
== 0x38)
3445 /* The variable dwarf_file_string tells stringer that the string
3446 may be the name of the source file. */
3447 if (dwarf_file
== 4)
3448 dwarf_file_string
= 1;
3450 dwarf_file_string
= 0;
3455 if (check_eh_frame (exp
, &nbytes
))
3460 /* Allow `.word 0' in the absolute section. */
3461 if (now_seg
== absolute_section
)
3463 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3464 as_bad (_("attempt to store value in absolute section"));
3465 abs_section_offset
+= nbytes
;
3469 /* Handle a negative bignum. */
3471 && exp
->X_add_number
== 0
3472 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3473 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3476 unsigned long carry
;
3478 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3480 /* Negate the bignum: one's complement each digit and add 1. */
3482 for (i
= 0; i
< exp
->X_add_number
; i
++)
3486 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3489 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3490 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3493 /* We can ignore any carry out, because it will be handled by
3494 extra_digit if it is needed. */
3496 extra_digit
= (valueT
) -1;
3500 if (op
== O_absent
|| op
== O_illegal
)
3502 as_warn (_("zero assumed for missing expression"));
3503 exp
->X_add_number
= 0;
3506 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3508 as_bad (_("floating point number invalid; zero assumed"));
3509 exp
->X_add_number
= 0;
3512 else if (op
== O_register
)
3514 as_warn (_("register value used as expression"));
3518 p
= frag_more ((int) nbytes
);
3520 #ifndef WORKING_DOT_WORD
3521 /* If we have the difference of two symbols in a word, save it on
3522 the broken_words list. See the code in write.c. */
3523 if (op
== O_subtract
&& nbytes
== 2)
3525 struct broken_word
*x
;
3527 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3528 x
->next_broken_word
= broken_words
;
3531 x
->subseg
= now_subseg
;
3533 x
->word_goes_here
= p
;
3535 x
->add
= exp
->X_add_symbol
;
3536 x
->sub
= exp
->X_op_symbol
;
3537 x
->addnum
= exp
->X_add_number
;
3544 /* If we have an integer, but the number of bytes is too large to
3545 pass to md_number_to_chars, handle it as a bignum. */
3546 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3551 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3552 extra_digit
= (valueT
) -1;
3553 val
= (valueT
) exp
->X_add_number
;
3557 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3558 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3562 op
= exp
->X_op
= O_big
;
3563 exp
->X_add_number
= gencnt
;
3566 if (op
== O_constant
)
3568 register valueT get
;
3569 register valueT use
;
3570 register valueT mask
;
3572 register valueT unmask
;
3574 /* JF << of >= number of bits in the object is undefined. In
3575 particular SPARC (Sun 4) has problems. */
3576 if (nbytes
>= sizeof (valueT
))
3579 if (nbytes
> sizeof (valueT
))
3582 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3586 /* Don't store these bits. */
3587 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3588 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3591 unmask
= ~mask
; /* Do store these bits. */
3594 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3595 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3598 get
= exp
->X_add_number
;
3600 if ((get
& mask
) != 0
3601 && ((get
& mask
) != mask
3602 || (get
& hibit
) == 0))
3603 { /* Leading bits contain both 0s & 1s. */
3604 as_warn (_("Value 0x%lx truncated to 0x%lx."),
3605 (unsigned long) get
, (unsigned long) use
);
3607 /* Put bytes in right order. */
3608 md_number_to_chars (p
, use
, (int) nbytes
);
3610 else if (op
== O_big
)
3613 LITTLENUM_TYPE
*nums
;
3615 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3617 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3620 as_warn (_("Bignum truncated to %d bytes"), nbytes
);
3624 if (target_big_endian
)
3626 while (nbytes
> size
)
3628 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3629 nbytes
-= CHARS_PER_LITTLENUM
;
3630 p
+= CHARS_PER_LITTLENUM
;
3633 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3637 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3638 size
-= CHARS_PER_LITTLENUM
;
3639 p
+= CHARS_PER_LITTLENUM
;
3644 nums
= generic_bignum
;
3647 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3649 size
-= CHARS_PER_LITTLENUM
;
3650 p
+= CHARS_PER_LITTLENUM
;
3651 nbytes
-= CHARS_PER_LITTLENUM
;
3656 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3657 nbytes
-= CHARS_PER_LITTLENUM
;
3658 p
+= CHARS_PER_LITTLENUM
;
3664 memset (p
, 0, nbytes
);
3666 /* Now we need to generate a fixS to record the symbol value.
3667 This is easy for BFD. For other targets it can be more
3668 complex. For very complex cases (currently, the HPPA and
3669 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3670 want. For simpler cases, you can define TC_CONS_RELOC to be
3671 the name of the reloc code that should be stored in the fixS.
3672 If neither is defined, the code uses NO_RELOC if it is
3673 defined, and otherwise uses 0. */
3675 #ifdef BFD_ASSEMBLER
3676 #ifdef TC_CONS_FIX_NEW
3677 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3680 bfd_reloc_code_real_type r
;
3697 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3701 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3706 #ifdef TC_CONS_FIX_NEW
3707 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3709 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3710 it is defined, otherwise use NO_RELOC if it is defined,
3712 #ifndef TC_CONS_RELOC
3714 #define TC_CONS_RELOC NO_RELOC
3716 #define TC_CONS_RELOC 0
3719 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3721 #endif /* TC_CONS_FIX_NEW */
3722 #endif /* BFD_ASSEMBLER */
3726 #ifdef BITFIELD_CONS_EXPRESSIONS
3728 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3729 w:x,y:z, where w and y are bitwidths and x and y are values. They
3730 then pack them all together. We do a little better in that we allow
3731 them in words, longs, etc. and we'll pack them in target byte order
3734 The rules are: pack least significat bit first, if a field doesn't
3735 entirely fit, put it in the next unit. Overflowing the bitfield is
3736 explicitly *not* even a warning. The bitwidth should be considered
3739 To use this function the tc-XXX.h file should define
3740 BITFIELD_CONS_EXPRESSIONS. */
3743 parse_bitfield_cons (exp
, nbytes
)
3745 unsigned int nbytes
;
3747 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3748 char *hold
= input_line_pointer
;
3750 (void) expression (exp
);
3752 if (*input_line_pointer
== ':')
3759 unsigned long width
;
3761 if (*input_line_pointer
!= ':')
3763 input_line_pointer
= hold
;
3765 } /* Next piece is not a bitfield. */
3767 /* In the general case, we can't allow
3768 full expressions with symbol
3769 differences and such. The relocation
3770 entries for symbols not defined in this
3771 assembly would require arbitrary field
3772 widths, positions, and masks which most
3773 of our current object formats don't
3776 In the specific case where a symbol
3777 *is* defined in this assembly, we
3778 *could* build fixups and track it, but
3779 this could lead to confusion for the
3780 backends. I'm lazy. I'll take any
3781 SEG_ABSOLUTE. I think that means that
3782 you can use a previous .set or
3783 .equ type symbol. xoxorich. */
3785 if (exp
->X_op
== O_absent
)
3787 as_warn (_("using a bit field width of zero"));
3788 exp
->X_add_number
= 0;
3789 exp
->X_op
= O_constant
;
3790 } /* Implied zero width bitfield. */
3792 if (exp
->X_op
!= O_constant
)
3794 *input_line_pointer
= '\0';
3795 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3796 *input_line_pointer
= ':';
3797 demand_empty_rest_of_line ();
3799 } /* Too complex. */
3801 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3803 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3804 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3805 width
= BITS_PER_CHAR
* nbytes
;
3808 if (width
> bits_available
)
3810 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3811 input_line_pointer
= hold
;
3812 exp
->X_add_number
= value
;
3817 hold
= ++input_line_pointer
;
3819 (void) expression (exp
);
3820 if (exp
->X_op
!= O_constant
)
3822 char cache
= *input_line_pointer
;
3824 *input_line_pointer
= '\0';
3825 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3826 *input_line_pointer
= cache
;
3827 demand_empty_rest_of_line ();
3829 } /* Too complex. */
3831 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3832 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3834 if ((bits_available
-= width
) == 0
3835 || is_it_end_of_statement ()
3836 || *input_line_pointer
!= ',')
3839 } /* All the bitfields we're gonna get. */
3841 hold
= ++input_line_pointer
;
3842 (void) expression (exp
);
3845 exp
->X_add_number
= value
;
3846 exp
->X_op
= O_constant
;
3847 exp
->X_unsigned
= 1;
3851 #endif /* BITFIELD_CONS_EXPRESSIONS */
3853 /* Handle an MRI style string expression. */
3857 parse_mri_cons (exp
, nbytes
)
3859 unsigned int nbytes
;
3861 if (*input_line_pointer
!= '\''
3862 && (input_line_pointer
[1] != '\''
3863 || (*input_line_pointer
!= 'A'
3864 && *input_line_pointer
!= 'E')))
3865 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3869 unsigned int result
= 0;
3871 /* An MRI style string. Cut into as many bytes as will fit into
3872 a nbyte chunk, left justify if necessary, and separate with
3873 commas so we can try again later. */
3874 if (*input_line_pointer
== 'A')
3875 ++input_line_pointer
;
3876 else if (*input_line_pointer
== 'E')
3878 as_bad (_("EBCDIC constants are not supported"));
3879 ++input_line_pointer
;
3882 input_line_pointer
++;
3883 for (scan
= 0; scan
< nbytes
; scan
++)
3885 if (*input_line_pointer
== '\'')
3887 if (input_line_pointer
[1] == '\'')
3889 input_line_pointer
++;
3894 result
= (result
<< 8) | (*input_line_pointer
++);
3898 while (scan
< nbytes
)
3904 /* Create correct expression. */
3905 exp
->X_op
= O_constant
;
3906 exp
->X_add_number
= result
;
3908 /* Fake it so that we can read the next char too. */
3909 if (input_line_pointer
[0] != '\'' ||
3910 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3912 input_line_pointer
-= 2;
3913 input_line_pointer
[0] = ',';
3914 input_line_pointer
[1] = '\'';
3917 input_line_pointer
++;
3920 #endif /* TC_M68K */
3922 #ifdef REPEAT_CONS_EXPRESSIONS
3924 /* Parse a repeat expression for cons. This is used by the MIPS
3925 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3926 object file COUNT times.
3928 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3931 parse_repeat_cons (exp
, nbytes
)
3933 unsigned int nbytes
;
3940 if (*input_line_pointer
!= ':')
3942 /* No repeat count. */
3946 ++input_line_pointer
;
3947 expression (&count
);
3948 if (count
.X_op
!= O_constant
3949 || count
.X_add_number
<= 0)
3951 as_warn (_("Unresolvable or nonpositive repeat count; using 1"));
3955 /* The cons function is going to output this expression once. So we
3956 output it count - 1 times. */
3957 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3958 emit_expr (exp
, nbytes
);
3961 #endif /* REPEAT_CONS_EXPRESSIONS */
3963 /* Parse a floating point number represented as a hex constant. This
3964 permits users to specify the exact bits they want in the floating
3968 hex_float (float_type
, bytes
)
4002 as_bad (_("Unknown floating type type '%c'"), float_type
);
4006 /* It would be nice if we could go through expression to parse the
4007 hex constant, but if we get a bignum it's a pain to sort it into
4008 the buffer correctly. */
4010 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4014 /* The MRI assembler accepts arbitrary underscores strewn about
4015 through the hex constant, so we ignore them as well. */
4016 if (*input_line_pointer
== '_')
4018 ++input_line_pointer
;
4024 as_warn (_("Floating point constant too large"));
4027 d
= hex_value (*input_line_pointer
) << 4;
4028 ++input_line_pointer
;
4029 while (*input_line_pointer
== '_')
4030 ++input_line_pointer
;
4031 if (hex_p (*input_line_pointer
))
4033 d
+= hex_value (*input_line_pointer
);
4034 ++input_line_pointer
;
4036 if (target_big_endian
)
4039 bytes
[length
- i
- 1] = d
;
4045 if (target_big_endian
)
4046 memset (bytes
+ i
, 0, length
- i
);
4048 memset (bytes
, 0, length
- i
);
4056 CONStruct some more frag chars of .floats .ffloats etc.
4057 Makes 0 or more new frags.
4058 If need_pass_2 == 1, no frags are emitted.
4059 This understands only floating literals, not expressions. Sorry.
4061 A floating constant is defined by atof_generic(), except it is preceded
4062 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4063 reading, I decided to be incompatible. This always tries to give you
4064 rounded bits to the precision of the pseudo-op. Former AS did premature
4065 truncatation, restored noisy bits instead of trailing 0s AND gave you
4066 a choice of 2 flavours of noise according to which of 2 floating-point
4067 scanners you directed AS to use.
4069 In: input_line_pointer->whitespace before, or '0' of flonum. */
4072 float_cons (float_type
)
4073 /* Clobbers input_line-pointer, checks end-of-line. */
4074 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4077 int length
; /* Number of chars in an object. */
4078 register char *err
; /* Error from scanning floating literal. */
4079 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4081 if (is_it_end_of_statement ())
4083 demand_empty_rest_of_line ();
4087 #ifdef md_flush_pending_output
4088 md_flush_pending_output ();
4093 /* input_line_pointer->1st char of a flonum (we hope!). */
4096 /* Skip any 0{letter} that may be present. Don't even check if the
4097 letter is legal. Someone may invent a "z" format and this routine
4098 has no use for such information. Lusers beware: you get
4099 diagnostics if your input is ill-conditioned. */
4100 if (input_line_pointer
[0] == '0'
4101 && isalpha ((unsigned char) input_line_pointer
[1]))
4102 input_line_pointer
+= 2;
4104 /* Accept :xxxx, where the x's are hex digits, for a floating
4105 point with the exact digits specified. */
4106 if (input_line_pointer
[0] == ':')
4108 ++input_line_pointer
;
4109 length
= hex_float (float_type
, temp
);
4112 ignore_rest_of_line ();
4118 err
= md_atof (float_type
, temp
, &length
);
4119 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4123 as_bad (_("Bad floating literal: %s"), err
);
4124 ignore_rest_of_line ();
4135 #ifdef REPEAT_CONS_EXPRESSIONS
4136 if (*input_line_pointer
== ':')
4138 expressionS count_exp
;
4140 ++input_line_pointer
;
4141 expression (&count_exp
);
4143 if (count_exp
.X_op
!= O_constant
4144 || count_exp
.X_add_number
<= 0)
4145 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4147 count
= count_exp
.X_add_number
;
4151 while (--count
>= 0)
4153 p
= frag_more (length
);
4154 memcpy (p
, temp
, (unsigned int) length
);
4159 while (*input_line_pointer
++ == ',');
4161 /* Put terminator back into stream. */
4162 --input_line_pointer
;
4163 demand_empty_rest_of_line ();
4166 /* Return the size of a LEB128 value. */
4169 sizeof_sleb128 (value
)
4172 register int size
= 0;
4173 register unsigned byte
;
4177 byte
= (value
& 0x7f);
4178 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4179 Fortunately, we can structure things so that the extra work reduces
4180 to a noop on systems that do things "properly". */
4181 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4184 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4185 || ((value
== -1) && ((byte
& 0x40) != 0))));
4191 sizeof_uleb128 (value
)
4194 register int size
= 0;
4195 register unsigned byte
;
4199 byte
= (value
& 0x7f);
4209 sizeof_leb128 (value
, sign
)
4214 return sizeof_sleb128 ((offsetT
) value
);
4216 return sizeof_uleb128 (value
);
4219 /* Output a LEB128 value. */
4222 output_sleb128 (p
, value
)
4226 register char *orig
= p
;
4231 unsigned byte
= (value
& 0x7f);
4233 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4234 Fortunately, we can structure things so that the extra work reduces
4235 to a noop on systems that do things "properly". */
4236 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4238 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4239 || ((value
== -1) && ((byte
& 0x40) != 0))));
4251 output_uleb128 (p
, value
)
4259 unsigned byte
= (value
& 0x7f);
4262 /* More bytes to follow. */
4273 output_leb128 (p
, value
, sign
)
4279 return output_sleb128 (p
, (offsetT
) value
);
4281 return output_uleb128 (p
, value
);
4284 /* Do the same for bignums. We combine sizeof with output here in that
4285 we don't output for NULL values of P. It isn't really as critical as
4286 for "normal" values that this be streamlined. */
4289 output_big_sleb128 (p
, bignum
, size
)
4291 LITTLENUM_TYPE
*bignum
;
4299 /* Strip leading sign extensions off the bignum. */
4300 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4305 if (loaded
< 7 && size
> 0)
4307 val
|= (*bignum
<< loaded
);
4308 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4319 if ((val
== 0 && (byte
& 0x40) == 0)
4320 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4321 && (byte
& 0x40) != 0))
4329 while (byte
& 0x80);
4335 output_big_uleb128 (p
, bignum
, size
)
4337 LITTLENUM_TYPE
*bignum
;
4345 /* Strip leading zeros off the bignum. */
4346 /* XXX: Is this needed? */
4347 while (size
> 0 && bignum
[size
- 1] == 0)
4352 if (loaded
< 7 && size
> 0)
4354 val
|= (*bignum
<< loaded
);
4355 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4364 if (size
> 0 || val
)
4371 while (byte
& 0x80);
4377 output_big_leb128 (p
, bignum
, size
, sign
)
4379 LITTLENUM_TYPE
*bignum
;
4383 return output_big_sleb128 (p
, bignum
, size
);
4385 return output_big_uleb128 (p
, bignum
, size
);
4388 /* Generate the appropriate fragments for a given expression to emit a
4392 emit_leb128_expr (exp
, sign
)
4396 operatorT op
= exp
->X_op
;
4399 if (op
== O_absent
|| op
== O_illegal
)
4401 as_warn (_("zero assumed for missing expression"));
4402 exp
->X_add_number
= 0;
4405 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4407 as_bad (_("floating point number invalid; zero assumed"));
4408 exp
->X_add_number
= 0;
4411 else if (op
== O_register
)
4413 as_warn (_("register value used as expression"));
4417 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
4418 a signal that this is leb128 data. It shouldn't optimize this away. */
4420 if (check_eh_frame (exp
, &nbytes
))
4423 /* Let the backend know that subsequent data may be byte aligned. */
4424 #ifdef md_cons_align
4428 if (op
== O_constant
)
4430 /* If we've got a constant, emit the thing directly right now. */
4432 valueT value
= exp
->X_add_number
;
4436 size
= sizeof_leb128 (value
, sign
);
4437 p
= frag_more (size
);
4438 output_leb128 (p
, value
, sign
);
4440 else if (op
== O_big
)
4442 /* O_big is a different sort of constant. */
4447 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4448 p
= frag_more (size
);
4449 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4453 /* Otherwise, we have to create a variable sized fragment and
4454 resolve things later. */
4456 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4457 make_expr_symbol (exp
), 0, (char *) NULL
);
4461 /* Parse the .sleb128 and .uleb128 pseudos. */
4472 emit_leb128_expr (&exp
, sign
);
4474 while (*input_line_pointer
++ == ',');
4476 input_line_pointer
--;
4477 demand_empty_rest_of_line ();
4480 /* We read 0 or more ',' separated, double-quoted strings.
4481 Caller should have checked need_pass_2 is FALSE because we don't
4485 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4486 /* Checks end-of-line. */
4487 register int append_zero
; /* 0: don't append '\0', else 1. */
4489 register unsigned int c
;
4492 #ifdef md_flush_pending_output
4493 md_flush_pending_output ();
4496 /* The following awkward logic is to parse ZERO or more strings,
4497 comma separated. Recall a string expression includes spaces
4498 before the opening '\"' and spaces after the closing '\"'.
4499 We fake a leading ',' if there is (supposed to be)
4500 a 1st, expression. We keep demanding expressions for each ','. */
4501 if (is_it_end_of_statement ())
4503 c
= 0; /* Skip loop. */
4504 ++input_line_pointer
; /* Compensate for end of loop. */
4508 c
= ','; /* Do loop. */
4510 while (c
== ',' || c
== '<' || c
== '"')
4513 switch (*input_line_pointer
)
4516 ++input_line_pointer
; /*->1st char of string. */
4517 start
= input_line_pointer
;
4518 while (is_a_char (c
= next_char_of_string ()))
4520 FRAG_APPEND_1_CHAR (c
);
4524 FRAG_APPEND_1_CHAR (0);
4526 know (input_line_pointer
[-1] == '\"');
4530 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4531 will emit .string with a filename in the .debug section
4532 after a sequence of constants. See the comment in
4533 emit_expr for the sequence. emit_expr will set
4534 dwarf_file_string to non-zero if this string might be a
4535 source file name. */
4536 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4537 dwarf_file_string
= 0;
4538 else if (dwarf_file_string
)
4540 c
= input_line_pointer
[-1];
4541 input_line_pointer
[-1] = '\0';
4542 listing_source_file (start
);
4543 input_line_pointer
[-1] = c
;
4550 input_line_pointer
++;
4551 c
= get_single_number ();
4552 FRAG_APPEND_1_CHAR (c
);
4553 if (*input_line_pointer
!= '>')
4555 as_bad (_("Expected <nn>"));
4557 input_line_pointer
++;
4560 input_line_pointer
++;
4564 c
= *input_line_pointer
;
4567 demand_empty_rest_of_line ();
4570 /* FIXME-SOMEDAY: I had trouble here on characters with the
4571 high bits set. We'll probably also have trouble with
4572 multibyte chars, wide chars, etc. Also be careful about
4573 returning values bigger than 1 byte. xoxorich. */
4576 next_char_of_string ()
4578 register unsigned int c
;
4580 c
= *input_line_pointer
++ & CHAR_MASK
;
4588 as_warn (_("Unterminated string: Newline inserted."));
4589 bump_line_counters ();
4592 #ifndef NO_STRING_ESCAPES
4594 switch (c
= *input_line_pointer
++)
4622 break; /* As itself. */
4638 for (i
= 0, number
= 0;
4639 isdigit (c
) && i
< 3;
4640 c
= *input_line_pointer
++, i
++)
4642 number
= number
* 8 + c
- '0';
4647 --input_line_pointer
;
4656 c
= *input_line_pointer
++;
4657 while (isxdigit (c
))
4660 number
= number
* 16 + c
- '0';
4661 else if (isupper (c
))
4662 number
= number
* 16 + c
- 'A' + 10;
4664 number
= number
* 16 + c
- 'a' + 10;
4665 c
= *input_line_pointer
++;
4668 --input_line_pointer
;
4673 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4674 as_warn (_("Unterminated string: Newline inserted."));
4676 bump_line_counters ();
4681 #ifdef ONLY_STANDARD_ESCAPES
4682 as_bad (_("Bad escaped character in string, '?' assumed"));
4684 #endif /* ONLY_STANDARD_ESCAPES */
4689 #endif /* ! defined (NO_STRING_ESCAPES) */
4698 get_segmented_expression (expP
)
4699 register expressionS
*expP
;
4701 register segT retval
;
4703 retval
= expression (expP
);
4704 if (expP
->X_op
== O_illegal
4705 || expP
->X_op
== O_absent
4706 || expP
->X_op
== O_big
)
4708 as_bad (_("expected address expression; zero assumed"));
4709 expP
->X_op
= O_constant
;
4710 expP
->X_add_number
= 0;
4711 retval
= absolute_section
;
4717 get_known_segmented_expression (expP
)
4718 register expressionS
*expP
;
4720 register segT retval
;
4722 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4724 /* There is no easy way to extract the undefined symbol from the
4726 if (expP
->X_add_symbol
!= NULL
4727 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4728 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4729 S_GET_NAME (expP
->X_add_symbol
));
4731 as_warn (_("some symbol undefined; zero assumed"));
4732 retval
= absolute_section
;
4733 expP
->X_op
= O_constant
;
4734 expP
->X_add_number
= 0;
4736 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4741 get_absolute_expression ()
4746 if (exp
.X_op
!= O_constant
)
4748 if (exp
.X_op
!= O_absent
)
4749 as_bad (_("bad or irreducible absolute expression; zero assumed"));
4750 exp
.X_add_number
= 0;
4752 return exp
.X_add_number
;
4755 char /* Return terminator. */
4756 get_absolute_expression_and_terminator (val_pointer
)
4757 long *val_pointer
; /* Return value of expression. */
4759 /* FIXME: val_pointer should probably be offsetT *. */
4760 *val_pointer
= (long) get_absolute_expression ();
4761 return (*input_line_pointer
++);
4764 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4765 Give a warning if that happens. */
4768 demand_copy_C_string (len_pointer
)
4773 if ((s
= demand_copy_string (len_pointer
)) != 0)
4777 for (len
= *len_pointer
; len
> 0; len
--)
4784 as_bad (_("This string may not contain \'\\0\'"));
4792 /* Demand string, but return a safe (=private) copy of the string.
4793 Return NULL if we can't read a string here. */
4796 demand_copy_string (lenP
)
4799 register unsigned int c
;
4805 if (*input_line_pointer
== '\"')
4807 input_line_pointer
++; /* Skip opening quote. */
4809 while (is_a_char (c
= next_char_of_string ()))
4811 obstack_1grow (¬es
, c
);
4814 /* JF this next line is so demand_copy_C_string will return a
4815 null terminated string. */
4816 obstack_1grow (¬es
, '\0');
4817 retval
= obstack_finish (¬es
);
4821 as_warn (_("Missing string"));
4823 ignore_rest_of_line ();
4829 /* In: Input_line_pointer->next character.
4831 Do: Skip input_line_pointer over all whitespace.
4833 Out: 1 if input_line_pointer->end-of-line. */
4836 is_it_end_of_statement ()
4839 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4843 equals (sym_name
, reassign
)
4847 register symbolS
*symbolP
; /* Symbol we are working with. */
4851 input_line_pointer
++;
4852 if (*input_line_pointer
== '=')
4853 input_line_pointer
++;
4855 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4856 input_line_pointer
++;
4859 stop
= mri_comment_field (&stopc
);
4861 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4863 /* Turn '. = mumble' into a .org mumble. */
4864 register segT segment
;
4867 segment
= get_known_segmented_expression (&exp
);
4869 do_org (segment
, &exp
, 0);
4876 symbolP
= symbol_find (sym_name
);
4877 local
= symbolP
== NULL
;
4879 #endif /* OBJ_COFF */
4880 symbolP
= symbol_find_or_make (sym_name
);
4881 /* Permit register names to be redefined. */
4883 && S_IS_DEFINED (symbolP
)
4884 && S_GET_SEGMENT (symbolP
) != reg_section
)
4885 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
4888 /* "set" symbols are local unless otherwise specified. */
4890 SF_SET_LOCAL (symbolP
);
4891 #endif /* OBJ_COFF */
4893 pseudo_set (symbolP
);
4898 /* Check garbage after the expression. */
4899 ignore_rest_of_line ();
4900 mri_comment_end (stop
, stopc
);
4904 /* .incbin -- include a file verbatim at the current location. */
4908 int x ATTRIBUTE_UNUSED
;
4919 #ifdef md_flush_pending_output
4920 md_flush_pending_output ();
4924 filename
= demand_copy_string (& len
);
4925 if (filename
== NULL
)
4930 /* Look for optional skip and count. */
4931 if (* input_line_pointer
== ',')
4933 ++ input_line_pointer
;
4934 skip
= get_absolute_expression ();
4938 if (* input_line_pointer
== ',')
4940 ++ input_line_pointer
;
4942 count
= get_absolute_expression ();
4944 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
4950 demand_empty_rest_of_line ();
4952 /* Try opening absolute path first, then try include dirs. */
4953 binfile
= fopen (filename
, FOPEN_RB
);
4954 if (binfile
== NULL
)
4958 path
= xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
4960 for (i
= 0; i
< include_dir_count
; i
++)
4962 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
4964 binfile
= fopen (path
, FOPEN_RB
);
4965 if (binfile
!= NULL
)
4969 if (binfile
== NULL
)
4970 as_bad (_("file not found: %s"), filename
);
4973 path
= xstrdup (filename
);
4979 register_dependency (path
);
4981 /* Compute the length of the file. */
4982 if (fseek (binfile
, 0, SEEK_END
) != 0)
4984 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
4987 file_len
= ftell (binfile
);
4989 /* If a count was not specified use the size of the file. */
4993 if (skip
+ count
> file_len
)
4995 as_bad (_("skip (%ld) + count (%ld) larger than file size (%ld)"),
4996 skip
, count
, file_len
);
5000 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
5002 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
5006 /* Allocate frag space and store file contents in it. */
5007 binfrag
= frag_more (count
);
5009 bytes
= fread (binfrag
, 1, count
, binfile
);
5011 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5012 path
, bytes
, count
);
5015 if (binfile
!= NULL
)
5021 /* .include -- include a file at this point. */
5025 int arg ATTRIBUTE_UNUSED
;
5034 filename
= demand_copy_string (&i
);
5035 if (filename
== NULL
)
5037 /* demand_copy_string has already printed an error and
5038 called ignore_rest_of_line. */
5046 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5047 && *input_line_pointer
!= ' '
5048 && *input_line_pointer
!= '\t')
5050 obstack_1grow (¬es
, *input_line_pointer
);
5051 ++input_line_pointer
;
5055 obstack_1grow (¬es
, '\0');
5056 filename
= obstack_finish (¬es
);
5057 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5058 ++input_line_pointer
;
5061 demand_empty_rest_of_line ();
5062 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
5064 for (i
= 0; i
< include_dir_count
; i
++)
5066 strcpy (path
, include_dirs
[i
]);
5068 strcat (path
, filename
);
5069 if (0 != (try = fopen (path
, FOPEN_RT
)))
5079 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5080 register_dependency (path
);
5081 input_scrub_insert_file (path
);
5085 add_include_dir (path
)
5090 if (include_dir_count
== 0)
5092 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5093 include_dirs
[0] = "."; /* Current dir. */
5094 include_dir_count
= 2;
5098 include_dir_count
++;
5100 (char **) realloc (include_dirs
,
5101 include_dir_count
* sizeof (*include_dirs
));
5104 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5107 if (i
> include_dir_maxlen
)
5108 include_dir_maxlen
= i
;
5111 /* Output debugging information to denote the source file. */
5114 generate_file_debug ()
5116 if (debug_type
== DEBUG_STABS
)
5117 stabs_generate_asm_file ();
5120 /* Output line number debugging information for the current source line. */
5123 generate_lineno_debug ()
5127 case DEBUG_UNSPECIFIED
:
5132 stabs_generate_asm_lineno ();
5135 ecoff_generate_asm_lineno ();
5138 /* ??? We could here indicate to dwarf2dbg.c that something
5139 has changed. However, since there is additional backend
5140 support that is required (calling dwarf2_emit_insn), we
5141 let dwarf2dbg.c call as_where on its own. */
5146 /* Output debugging information to mark a function entry point or end point.
5147 END_P is zero for .func, and non-zero for .endfunc. */
5153 do_s_func (end_p
, NULL
);
5156 /* Subroutine of s_func so targets can choose a different default prefix.
5157 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5160 do_s_func (end_p
, default_prefix
)
5162 const char *default_prefix
;
5164 /* Record the current function so that we can issue an error message for
5165 misplaced .func,.endfunc, and also so that .endfunc needs no
5167 static char *current_name
;
5168 static char *current_label
;
5172 if (current_name
== NULL
)
5174 as_bad (_("missing .func"));
5175 ignore_rest_of_line ();
5179 if (debug_type
== DEBUG_STABS
)
5180 stabs_generate_asm_endfunc (current_name
, current_label
);
5182 current_name
= current_label
= NULL
;
5187 char delim1
, delim2
;
5189 if (current_name
!= NULL
)
5191 as_bad (_(".endfunc missing for previous .func"));
5192 ignore_rest_of_line ();
5196 name
= input_line_pointer
;
5197 delim1
= get_symbol_end ();
5198 name
= xstrdup (name
);
5199 *input_line_pointer
= delim1
;
5201 if (*input_line_pointer
!= ',')
5204 asprintf (&label
, "%s%s", default_prefix
, name
);
5207 char leading_char
= 0;
5208 #ifdef BFD_ASSEMBLER
5209 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5211 /* Missing entry point, use function's name with the leading
5214 asprintf (&label
, "%c%s", leading_char
, name
);
5221 ++input_line_pointer
;
5223 label
= input_line_pointer
;
5224 delim2
= get_symbol_end ();
5225 label
= xstrdup (label
);
5226 *input_line_pointer
= delim2
;
5229 if (debug_type
== DEBUG_STABS
)
5230 stabs_generate_asm_func (name
, label
);
5232 current_name
= name
;
5233 current_label
= label
;
5236 demand_empty_rest_of_line ();
5241 int arg ATTRIBUTE_UNUSED
;
5243 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5245 ++input_line_pointer
;
5247 ++input_line_pointer
;
5251 read_print_statistics (file
)
5254 hash_print_statistics (file
, "pseudo-op table", po_hash
);
5257 /* Inserts the given line into the input stream.
5259 This call avoids macro/conditionals nesting checking, since the contents of
5260 the line are assumed to replace the contents of a line already scanned.
5262 An appropriate use of this function would be substition of input lines when
5263 called by md_start_line_hook(). The given line is assumed to already be
5264 properly scrubbed. */
5267 input_scrub_insert_line (line
)
5272 sb_add_string (&newline
, line
);
5273 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
5275 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
5278 /* Insert a file into the input stream; the path must resolve to an actual
5279 file; no include path searching or dependency registering is performed. */
5282 input_scrub_insert_file (path
)
5285 input_scrub_include_file (path
, input_line_pointer
);
5286 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);