1 /* read.c - read a source file -
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* If your chars aren't 8 bits, you will change this a bit.
24 But then, GNU isn't spozed to run on your machine anyway.
25 (RMS is so shortsighted sometimes.) */
26 #define MASK_CHAR (0xFF)
28 #define MASK_CHAR ((int)(unsigned char) -1)
31 /* This is the largest known floating point format (for now). It will
32 grow when we do 4361 style flonums. */
33 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
35 /* Routines that read assembler source text to build spaghetti in memory.
36 Another group of these functions is in the expr.c module. */
39 #include "safe-ctype.h"
46 #include "dw2gencfi.h"
48 #ifndef TC_START_LABEL
49 #define TC_START_LABEL(x,y) (x == ':')
52 /* Set by the object-format or the target. */
53 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
54 #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
59 else if ((SIZE) >= 4) \
61 else if ((SIZE) >= 2) \
69 char *input_line_pointer
; /*->next char of source file to parse. */
71 #if BITS_PER_CHAR != 8
72 /* The following table is indexed by[(char)] and will break if
73 a char does not have exactly 256 states (hopefully 0:255!)! */
78 /* The m88k unfortunately uses @ as a label beginner. */
83 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
88 /* The Delta 68k assembler permits % inside label names. */
93 /* The PowerPC Windows NT assemblers permits ? inside label names. */
98 /* The IA-64 assembler uses # as a suffix designating a symbol. We include
99 it in the symbol and strip it out in tc_canonicalize_symbol_name. */
104 /* The a29k assembler does not permits labels to start with $. */
109 /* The Delta 68k assembler permits ~ at start of label names. */
113 /* Used by is_... macros. our ctype[]. */
114 char lex_type
[256] = {
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
117 0, 0, 0, LEX_HASH
, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
118 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
119 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
120 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
121 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
122 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
123 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
124 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
125 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
126 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
127 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
128 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
129 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
130 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
134 Out: 1 if this character ends a line. */
135 char is_end_of_line
[256] = {
137 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, /* @abcdefghijklmno */
139 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* @abcdefghijklmno */
141 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* _!"#$%&'()*+,-./ */
143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
145 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
146 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
149 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
150 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* */
158 #ifdef IGNORE_OPCODE_CASE
159 char original_case_string
[128];
162 /* Functions private to this file. */
164 static char *buffer
; /* 1st char of each buffer of lines is here. */
165 static char *buffer_limit
; /*->1 + last char in buffer. */
167 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
168 in the tc-<CPU>.h file. See the "Porting GAS" section of the
170 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
172 /* Variables for handling include file directory table. */
174 /* Table of pointers to directories to search for .include's. */
177 /* How many are in the table. */
178 int include_dir_count
;
180 /* Length of longest in table. */
181 int include_dir_maxlen
= 1;
183 #ifndef WORKING_DOT_WORD
184 struct broken_word
*broken_words
;
185 int new_broken_words
;
188 /* The current offset into the absolute section. We don't try to
189 build frags in the absolute section, since no data can be stored
190 there. We just keep track of the current offset. */
191 addressT abs_section_offset
;
193 /* If this line had an MRI style label, it is stored in this variable.
194 This is used by some of the MRI pseudo-ops. */
197 /* This global variable is used to support MRI common sections. We
198 translate such sections into a common symbol. This variable is
199 non-NULL when we are in an MRI common section. */
200 symbolS
*mri_common_symbol
;
202 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
203 need to align to an even byte boundary unless the next pseudo-op is
204 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
206 static int mri_pending_align
;
210 /* This variable is set to be non-zero if the next string we see might
211 be the name of the source file in DWARF debugging information. See
212 the comment in emit_expr for the format we look for. */
213 static int dwarf_file_string
;
217 static void cons_worker (int, int);
218 static int scrub_from_string (char *, int);
219 static void do_align (int, char *, int, int);
220 static void s_align (int, int);
221 static void s_lcomm_internal (int, int);
222 static int hex_float (int, char *);
223 static inline int sizeof_sleb128 (offsetT
);
224 static inline int sizeof_uleb128 (valueT
);
225 static inline int output_sleb128 (char *, offsetT
);
226 static inline int output_uleb128 (char *, valueT
);
227 static inline int output_big_sleb128 (char *, LITTLENUM_TYPE
*, int);
228 static inline int output_big_uleb128 (char *, LITTLENUM_TYPE
*, int);
229 static int output_big_leb128 (char *, LITTLENUM_TYPE
*, int, int);
230 static void do_org (segT
, expressionS
*, int);
231 char *demand_copy_string (int *lenP
);
232 static segT
get_segmented_expression (expressionS
*expP
);
233 static segT
get_known_segmented_expression (expressionS
* expP
);
234 static void pobegin (void);
235 static int get_line_sb (sb
*);
236 static void generate_file_debug (void);
244 obj_read_begin_hook ();
246 /* Something close -- but not too close -- to a multiple of 1024.
247 The debugging malloc I'm using has 24 bytes of overhead. */
248 obstack_begin (¬es
, chunksize
);
249 obstack_begin (&cond_obstack
, chunksize
);
251 /* Use machine dependent syntax. */
252 for (p
= line_separator_chars
; *p
; p
++)
253 is_end_of_line
[(unsigned char) *p
] = 1;
254 /* Use more. FIXME-SOMEDAY. */
260 /* Set up pseudo-op tables. */
262 static struct hash_control
*po_hash
;
264 static const pseudo_typeS potable
[] = {
265 {"abort", s_abort
, 0},
266 {"align", s_align_ptwo
, 0},
267 {"ascii", stringer
, 0},
268 {"asciz", stringer
, 1},
269 {"balign", s_align_bytes
, 0},
270 {"balignw", s_align_bytes
, -2},
271 {"balignl", s_align_bytes
, -4},
275 {"common", s_mri_common
, 0},
276 {"common.s", s_mri_common
, 1},
280 {"dc.d", float_cons
, 'd'},
282 {"dc.s", float_cons
, 'f'},
284 {"dc.x", float_cons
, 'x'},
286 {"dcb.b", s_space
, 1},
287 {"dcb.d", s_float_space
, 'd'},
288 {"dcb.l", s_space
, 4},
289 {"dcb.s", s_float_space
, 'f'},
290 {"dcb.w", s_space
, 2},
291 {"dcb.x", s_float_space
, 'x'},
293 {"ds.b", s_space
, 1},
294 {"ds.d", s_space
, 8},
295 {"ds.l", s_space
, 4},
296 {"ds.p", s_space
, 12},
297 {"ds.s", s_space
, 4},
298 {"ds.w", s_space
, 2},
299 {"ds.x", s_space
, 12},
300 {"debug", s_ignore
, 0},
305 {"double", float_cons
, 'd'},
307 {"eject", listing_eject
, 0}, /* Formfeed listing. */
309 {"elsec", s_else
, 0},
310 {"elseif", s_elseif
, (int) O_ne
},
312 {"endc", s_endif
, 0},
313 {"endfunc", s_func
, 1},
314 {"endif", s_endif
, 0},
315 {"endr", s_bad_endr
, 0},
320 {"exitm", s_mexit
, 0},
322 {"extern", s_ignore
, 0}, /* We treat all undef as ext. */
323 {"appfile", s_app_file
, 1},
324 {"appline", s_app_line
, 0},
326 {"file", s_app_file
, 0},
328 {"float", float_cons
, 'f'},
329 {"format", s_ignore
, 0},
331 {"global", s_globl
, 0},
332 {"globl", s_globl
, 0},
334 {"if", s_if
, (int) O_ne
},
336 {"ifdef", s_ifdef
, 0},
337 {"ifeq", s_if
, (int) O_eq
},
338 {"ifeqs", s_ifeqs
, 0},
339 {"ifge", s_if
, (int) O_ge
},
340 {"ifgt", s_if
, (int) O_gt
},
341 {"ifle", s_if
, (int) O_le
},
342 {"iflt", s_if
, (int) O_lt
},
344 {"ifndef", s_ifdef
, 1},
345 {"ifne", s_if
, (int) O_ne
},
346 {"ifnes", s_ifeqs
, 1},
347 {"ifnotdef", s_ifdef
, 1},
348 {"incbin", s_incbin
, 0},
349 {"include", s_include
, 0},
355 {"lcomm", s_lcomm
, 0},
356 {"lflags", listing_flags
, 0}, /* Listing flags. */
357 {"linkonce", s_linkonce
, 0},
358 {"list", listing_list
, 1}, /* Turn listing on. */
359 {"llen", listing_psize
, 1},
362 {"macro", s_macro
, 0},
363 {"mexit", s_mexit
, 0},
365 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
366 {"name", s_ignore
, 0},
367 {"noformat", s_ignore
, 0},
368 {"nolist", listing_list
, 0}, /* Turn listing off. */
369 {"nopage", listing_nopage
, 0},
371 {"offset", s_struct
, 0},
373 {"p2align", s_align_ptwo
, 0},
374 {"p2alignw", s_align_ptwo
, -2},
375 {"p2alignl", s_align_ptwo
, -4},
376 {"page", listing_eject
, 0},
377 {"plen", listing_psize
, 0},
378 {"print", s_print
, 0},
379 {"psize", listing_psize
, 0}, /* Set paper size. */
380 {"purgem", s_purgem
, 0},
385 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
390 {"single", float_cons
, 'f'},
392 {"space", s_space
, 0},
393 {"skip", s_space
, 0},
394 {"sleb128", s_leb128
, 1},
395 {"spc", s_ignore
, 0},
396 {"stabd", s_stab
, 'd'},
397 {"stabn", s_stab
, 'n'},
398 {"stabs", s_stab
, 's'},
399 {"string", stringer
, 1},
400 {"struct", s_struct
, 0},
404 /* This is for gcc to use. It's only just been added (2/94), so gcc
405 won't be able to use it for a while -- probably a year or more.
406 But once this has been released, check with gcc maintainers
407 before deleting it or even changing the spelling. */
408 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
409 /* If we're folding case -- done for some targets, not necessarily
410 all -- the above string in an input file will be converted to
411 this one. Match it either way... */
412 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
414 {"title", listing_title
, 0}, /* Listing title. */
415 {"ttl", listing_title
, 0},
417 {"uleb128", s_leb128
, 0},
421 {"xdef", s_globl
, 0},
422 {"xref", s_ignore
, 0},
423 {"xstabs", s_xstab
, 's'},
425 {"zero", s_space
, 0},
426 {NULL
, NULL
, 0} /* End sentinel. */
429 static int pop_override_ok
= 0;
430 static const char *pop_table_name
;
433 pop_insert (const pseudo_typeS
*table
)
436 const pseudo_typeS
*pop
;
437 for (pop
= table
; pop
->poc_name
; pop
++)
439 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
440 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
441 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
446 #ifndef md_pop_insert
447 #define md_pop_insert() pop_insert(md_pseudo_table)
450 #ifndef obj_pop_insert
451 #define obj_pop_insert() pop_insert(obj_pseudo_table)
454 #ifndef cfi_pop_insert
455 #define cfi_pop_insert() pop_insert(cfi_pseudo_table)
461 po_hash
= hash_new ();
463 /* Do the target-specific pseudo ops. */
464 pop_table_name
= "md";
467 /* Now object specific. Skip any that were in the target table. */
468 pop_table_name
= "obj";
472 /* Now portable ones. Skip any that we've seen already. */
473 pop_table_name
= "standard";
474 pop_insert (potable
);
476 #ifdef TARGET_USE_CFIPOP
477 pop_table_name
= "cfi";
483 #define HANDLE_CONDITIONAL_ASSEMBLY() \
484 if (ignore_input ()) \
486 while (!is_end_of_line[(unsigned char) *input_line_pointer++]) \
487 if (input_line_pointer == buffer_limit) \
492 /* This function is used when scrubbing the characters between #APP
495 static char *scrub_string
;
496 static char *scrub_string_end
;
499 scrub_from_string (char *buf
, int buflen
)
503 copy
= scrub_string_end
- scrub_string
;
506 memcpy (buf
, scrub_string
, copy
);
507 scrub_string
+= copy
;
511 /* We read the file, putting things into a web that represents what we
512 have been reading. */
514 read_a_source_file (char *name
)
517 register char *s
; /* String of symbol, '\0' appended. */
525 buffer
= input_scrub_new_file (name
);
528 listing_newline (NULL
);
529 register_dependency (name
);
531 /* Generate debugging information before we've read anything in to denote
532 this file as the "main" source file and not a subordinate one
533 (e.g. N_SO vs N_SOL in stabs). */
534 generate_file_debug ();
536 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
537 { /* We have another line to parse. */
538 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
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 beginning 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 #ifdef tc_check_label
715 tc_check_label (line_label
);
717 /* Input_line_pointer->after ':'. */
721 || ((c
== ' ' || c
== '\t')
722 && input_line_pointer
[1] == '='
723 #ifdef TC_EQUAL_IN_INSN
724 && !TC_EQUAL_IN_INSN (c
, input_line_pointer
)
729 demand_empty_rest_of_line ();
733 /* Expect pseudo-op or machine instruction. */
736 #ifdef IGNORE_OPCODE_CASE
740 strncpy (original_case_string
, s2
, sizeof (original_case_string
));
741 original_case_string
[sizeof (original_case_string
) - 1] = 0;
750 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
752 /* The MRI assembler and the m88k use pseudo-ops
754 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
755 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
760 || (!flag_m68k_mri
&& *s
== '.'))
764 WARNING: c has next char, which may be end-of-line.
765 We lookup the pseudo-op table with s+1 because we
766 already know that the pseudo-op begins with a '.'. */
769 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
771 /* In MRI mode, we may need to insert an
772 automatic alignment directive. What a hack
774 if (mri_pending_align
776 || !((pop
->poc_handler
== cons
777 && pop
->poc_val
== 1)
778 || (pop
->poc_handler
== s_space
779 && pop
->poc_val
== 1)
780 #ifdef tc_conditional_pseudoop
781 || tc_conditional_pseudoop (pop
)
783 || pop
->poc_handler
== s_if
784 || pop
->poc_handler
== s_ifdef
785 || pop
->poc_handler
== s_ifc
786 || pop
->poc_handler
== s_ifeqs
787 || pop
->poc_handler
== s_else
788 || pop
->poc_handler
== s_endif
789 || pop
->poc_handler
== s_globl
790 || pop
->poc_handler
== s_ignore
)))
792 do_align (1, (char *) NULL
, 0, 0);
793 mri_pending_align
= 0;
795 if (line_label
!= NULL
)
797 symbol_set_frag (line_label
, frag_now
);
798 S_SET_VALUE (line_label
, frag_now_fix ());
802 /* Print the error msg now, while we still can. */
805 as_bad (_("unknown pseudo-op: `%s'"), s
);
806 *input_line_pointer
= c
;
811 /* Put it back for error messages etc. */
812 *input_line_pointer
= c
;
813 /* The following skip of whitespace is compulsory.
814 A well shaped space is sometimes all that separates
815 keyword from operands. */
816 if (c
== ' ' || c
== '\t')
817 input_line_pointer
++;
819 /* Input_line is restored.
820 Input_line_pointer->1st non-blank char
821 after pseudo-operation. */
822 (*pop
->poc_handler
) (pop
->poc_val
);
824 /* If that was .end, just get out now. */
825 if (pop
->poc_handler
== s_end
)
831 #ifdef QUOTES_IN_INSN
835 /* WARNING: c has char, which may be end-of-line. */
836 /* Also: input_line_pointer->`\0` where c was. */
837 *input_line_pointer
= c
;
838 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
840 #ifdef TC_EOL_IN_INSN
841 || TC_EOL_IN_INSN (input_line_pointer
)
845 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
847 #ifdef QUOTES_IN_INSN
850 else if (*input_line_pointer
== '"')
852 else if (*input_line_pointer
== '\\')
855 input_line_pointer
++;
858 c
= *input_line_pointer
;
859 *input_line_pointer
= '\0';
861 generate_lineno_debug ();
869 if (check_macro (s
, &out
, &err
, ¯o
))
873 *input_line_pointer
++ = c
;
874 input_scrub_include_sb (&out
,
875 input_line_pointer
, 1);
878 input_scrub_next_buffer (&input_line_pointer
);
880 md_macro_info (macro
);
886 if (mri_pending_align
)
888 do_align (1, (char *) NULL
, 0, 0);
889 mri_pending_align
= 0;
890 if (line_label
!= NULL
)
892 symbol_set_frag (line_label
, frag_now
);
893 S_SET_VALUE (line_label
, frag_now_fix ());
897 md_assemble (s
); /* Assemble 1 instruction. */
899 *input_line_pointer
++ = c
;
901 /* We resume loop AFTER the end-of-line from
908 /* Empty statement? */
909 if (is_end_of_line
[(unsigned char) c
])
912 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
) && ISDIGIT (c
))
914 /* local label ("4:") */
915 char *backup
= input_line_pointer
;
917 HANDLE_CONDITIONAL_ASSEMBLY ();
921 /* Read the whole number. */
922 while (ISDIGIT (*input_line_pointer
))
924 temp
= (temp
* 10) + *input_line_pointer
- '0';
925 ++input_line_pointer
;
928 if (LOCAL_LABELS_DOLLAR
929 && *input_line_pointer
== '$'
930 && *(input_line_pointer
+ 1) == ':')
932 input_line_pointer
+= 2;
934 if (dollar_label_defined (temp
))
936 as_fatal (_("label \"%d$\" redefined"), temp
);
939 define_dollar_label (temp
);
940 colon (dollar_label_name (temp
, 0));
945 && *input_line_pointer
++ == ':')
947 fb_label_instance_inc (temp
);
948 colon (fb_label_name (temp
, 0));
952 input_line_pointer
= backup
;
953 } /* local label ("4:") */
955 if (c
&& strchr (line_comment_chars
, c
))
956 { /* Its a comment. Better say APP or NO_APP. */
961 unsigned int new_length
;
964 bump_line_counters ();
965 s
= input_line_pointer
;
966 if (strncmp (s
, "APP\n", 4))
967 continue; /* We ignore it */
971 ends
= strstr (s
, "#NO_APP\n");
975 unsigned int tmp_len
;
978 /* The end of the #APP wasn't in this buffer. We
979 keep reading in buffers until we find the #NO_APP
980 that goes with this #APP There is one. The specs
982 tmp_len
= buffer_limit
- s
;
983 tmp_buf
= xmalloc (tmp_len
+ 1);
984 memcpy (tmp_buf
, s
, tmp_len
);
987 new_tmp
= input_scrub_next_buffer (&buffer
);
991 buffer_limit
= new_tmp
;
992 input_line_pointer
= buffer
;
993 ends
= strstr (buffer
, "#NO_APP\n");
997 num
= buffer_limit
- buffer
;
999 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
1000 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
1005 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1013 input_line_pointer
= ends
+ 8;
1017 scrub_string_end
= ends
;
1019 new_length
= ends
- s
;
1020 new_buf
= (char *) xmalloc (new_length
);
1027 space
= (new_buf
+ new_length
) - new_tmp
;
1028 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1036 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1037 new_tmp
= new_buf
+ new_length
;
1044 /* We've "scrubbed" input to the preferred format. In the
1045 process we may have consumed the whole of the remaining
1046 file (and included files). We handle this formatted
1047 input similar to that of macro expansion, letting
1048 actual macro expansion (possibly nested) and other
1049 input expansion work. Beware that in messages, line
1050 numbers and possibly file names will be incorrect. */
1051 sb_add_string (&sbuf
, new_buf
);
1052 input_scrub_include_sb (&sbuf
, input_line_pointer
, 0);
1054 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1059 HANDLE_CONDITIONAL_ASSEMBLY ();
1061 #ifdef tc_unrecognized_line
1062 if (tc_unrecognized_line (c
))
1065 input_line_pointer
--;
1066 /* Report unknown char as ignored. */
1067 ignore_rest_of_line ();
1070 #ifdef md_after_pass_hook
1071 md_after_pass_hook ();
1080 /* Close the input file. */
1081 input_scrub_close ();
1082 #ifdef WARN_COMMENTS
1084 if (warn_comment
&& found_comment
)
1085 as_warn_where (found_comment_file
, found_comment
,
1086 "first comment found here");
1091 /* For most MRI pseudo-ops, the line actually ends at the first
1092 nonquoted space. This function looks for that point, stuffs a null
1093 in, and sets *STOPCP to the character that used to be there, and
1094 returns the location.
1096 Until I hear otherwise, I am going to assume that this is only true
1097 for the m68k MRI assembler. */
1100 mri_comment_field (char *stopcp
)
1106 know (flag_m68k_mri
);
1108 for (s
= input_line_pointer
;
1109 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1117 for (s
= input_line_pointer
;
1118 !is_end_of_line
[(unsigned char) *s
];
1128 /* Skip to the end of an MRI comment field. */
1131 mri_comment_end (char *stop
, int stopc
)
1135 input_line_pointer
= stop
;
1137 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1138 ++input_line_pointer
;
1142 s_abort (int ignore ATTRIBUTE_UNUSED
)
1144 as_fatal (_(".abort detected. Abandoning ship."));
1147 /* Guts of .align directive. N is the power of two to which to align.
1148 FILL may be NULL, or it may point to the bytes of the fill pattern.
1149 LEN is the length of whatever FILL points to, if anything. MAX is
1150 the maximum number of characters to skip when doing the alignment,
1151 or 0 if there is no maximum. */
1154 do_align (int n
, char *fill
, int len
, int max
)
1156 if (now_seg
== absolute_section
)
1160 if (*fill
++ != '\0')
1162 as_warn (_("ignoring fill value in absolute section"));
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
: ATTRIBUTE_UNUSED_LABEL
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 (int arg
, int bytes_p
)
1204 register unsigned int align
;
1212 stop
= mri_comment_field (&stopc
);
1214 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1219 align
= arg
; /* Default value from pseudo-op table. */
1223 align
= get_absolute_expression ();
1229 /* Convert to a power of 2. */
1234 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1237 as_bad (_("alignment not a power of 2"));
1246 as_warn (_("alignment too large: %u assumed"), align
);
1249 if (*input_line_pointer
!= ',')
1256 ++input_line_pointer
;
1257 if (*input_line_pointer
== ',')
1261 fill
= get_absolute_expression ();
1266 if (*input_line_pointer
!= ',')
1270 ++input_line_pointer
;
1271 max
= get_absolute_expression ();
1278 as_warn (_("expected fill pattern missing"));
1279 do_align (align
, (char *) NULL
, 0, max
);
1294 do_align (align
, &fill_char
, fill_len
, max
);
1300 if ((size_t) fill_len
> sizeof ab
)
1302 md_number_to_chars (ab
, fill
, fill_len
);
1303 do_align (align
, ab
, fill_len
, max
);
1307 demand_empty_rest_of_line ();
1310 mri_comment_end (stop
, stopc
);
1313 /* Handle the .align pseudo-op on machines where ".align 4" means
1314 align to a 4 byte boundary. */
1317 s_align_bytes (int arg
)
1322 /* Handle the .align pseudo-op on machines where ".align 4" means align
1323 to a 2**4 boundary. */
1326 s_align_ptwo (int arg
)
1332 s_comm (int ignore ATTRIBUTE_UNUSED
)
1334 register char *name
;
1338 register symbolS
*symbolP
;
1343 stop
= mri_comment_field (&stopc
);
1345 name
= input_line_pointer
;
1346 c
= get_symbol_end ();
1347 /* Just after name is now '\0'. */
1348 p
= input_line_pointer
;
1353 as_bad (_("expected symbol name"));
1354 discard_rest_of_line ();
1360 if (*input_line_pointer
!= ',')
1363 as_bad (_("expected comma after \"%s\""), name
);
1365 ignore_rest_of_line ();
1367 mri_comment_end (stop
, stopc
);
1371 input_line_pointer
++; /* skip ',' */
1373 if ((temp
= get_absolute_expression ()) < 0)
1375 as_warn (_(".COMMon length (%lu) out of range ignored"),
1376 (unsigned long) temp
);
1377 ignore_rest_of_line ();
1379 mri_comment_end (stop
, stopc
);
1384 symbolP
= symbol_find_or_make (name
);
1387 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1389 as_bad (_("symbol `%s' is already defined"),
1390 S_GET_NAME (symbolP
));
1391 ignore_rest_of_line ();
1393 mri_comment_end (stop
, stopc
);
1397 if (S_GET_VALUE (symbolP
))
1399 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1400 as_bad (_("length of .comm \"%s\" is already %ld; not changing to %ld"),
1401 S_GET_NAME (symbolP
),
1402 (long) S_GET_VALUE (symbolP
),
1407 S_SET_VALUE (symbolP
, (valueT
) temp
);
1408 S_SET_EXTERNAL (symbolP
);
1412 extern int flag_one
;
1413 if (!temp
|| !flag_one
)
1414 S_GET_OTHER(symbolP
) = const_flag
;
1416 #endif /* not OBJ_VMS */
1417 know (symbolP
->sy_frag
== &zero_address_frag
);
1419 demand_empty_rest_of_line ();
1422 mri_comment_end (stop
, stopc
);
1425 /* The MRI COMMON pseudo-op. We handle this by creating a common
1426 symbol with the appropriate name. We make s_space do the right
1427 thing by increasing the size. */
1430 s_mri_common (int small ATTRIBUTE_UNUSED
)
1446 stop
= mri_comment_field (&stopc
);
1450 name
= input_line_pointer
;
1451 if (!ISDIGIT (*name
))
1452 c
= get_symbol_end ();
1457 ++input_line_pointer
;
1459 while (ISDIGIT (*input_line_pointer
));
1461 c
= *input_line_pointer
;
1462 *input_line_pointer
= '\0';
1464 if (line_label
!= NULL
)
1466 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1467 + (input_line_pointer
- name
)
1469 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1474 sym
= symbol_find_or_make (name
);
1475 *input_line_pointer
= c
;
1479 if (*input_line_pointer
!= ',')
1483 ++input_line_pointer
;
1484 align
= get_absolute_expression ();
1487 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1489 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1490 ignore_rest_of_line ();
1491 mri_comment_end (stop
, stopc
);
1495 S_SET_EXTERNAL (sym
);
1496 mri_common_symbol
= sym
;
1500 S_SET_ALIGN (sym
, align
);
1503 if (line_label
!= NULL
)
1506 exp
.X_op
= O_symbol
;
1507 exp
.X_add_symbol
= sym
;
1508 exp
.X_add_number
= 0;
1509 symbol_set_value_expression (line_label
, &exp
);
1510 symbol_set_frag (line_label
, &zero_address_frag
);
1511 S_SET_SEGMENT (line_label
, expr_section
);
1514 /* FIXME: We just ignore the small argument, which distinguishes
1515 COMMON and COMMON.S. I don't know what we can do about it. */
1517 /* Ignore the type and hptype. */
1518 if (*input_line_pointer
== ',')
1519 input_line_pointer
+= 2;
1520 if (*input_line_pointer
== ',')
1521 input_line_pointer
+= 2;
1523 demand_empty_rest_of_line ();
1525 mri_comment_end (stop
, stopc
);
1529 s_data (int ignore ATTRIBUTE_UNUSED
)
1534 temp
= get_absolute_expression ();
1535 if (flag_readonly_data_in_text
)
1537 section
= text_section
;
1541 section
= data_section
;
1543 subseg_set (section
, (subsegT
) temp
);
1548 demand_empty_rest_of_line ();
1551 /* Handle the .appfile pseudo-op. This is automatically generated by
1552 do_scrub_chars when a preprocessor # line comment is seen with a
1553 file name. This default definition may be overridden by the object
1554 or CPU specific pseudo-ops. This function is also the default
1555 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1559 s_app_file_string (char *file
)
1563 listing_source_file (file
);
1565 register_dependency (file
);
1567 obj_app_file (file
);
1572 s_app_file (int appfile
)
1577 /* Some assemblers tolerate immediately following '"'. */
1578 if ((s
= demand_copy_string (&length
)) != 0)
1580 /* If this is a fake .appfile, a fake newline was inserted into
1581 the buffer. Passing -2 to new_logical_line tells it to
1584 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1586 /* In MRI mode, the preprocessor may have inserted an extraneous
1589 && *input_line_pointer
== '\''
1590 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1591 ++input_line_pointer
;
1593 demand_empty_rest_of_line ();
1595 s_app_file_string (s
);
1599 /* Handle the .appline pseudo-op. This is automatically generated by
1600 do_scrub_chars when a preprocessor # line comment is seen. This
1601 default definition may be overridden by the object or CPU specific
1605 s_app_line (int ignore ATTRIBUTE_UNUSED
)
1609 /* The given number is that of the next line. */
1610 l
= get_absolute_expression () - 1;
1612 /* Some of the back ends can't deal with non-positive line numbers.
1613 Besides, it's silly. */
1614 as_warn (_("line numbers must be positive; line number %d rejected"),
1618 new_logical_line ((char *) NULL
, l
);
1621 listing_source_line (l
);
1624 demand_empty_rest_of_line ();
1627 /* Handle the .end pseudo-op. Actually, the real work is done in
1628 read_a_source_file. */
1631 s_end (int ignore ATTRIBUTE_UNUSED
)
1635 /* The MRI assembler permits the start symbol to follow .end,
1636 but we don't support that. */
1638 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1639 && *input_line_pointer
!= '*'
1640 && *input_line_pointer
!= '!')
1641 as_warn (_("start address not supported"));
1645 /* Handle the .err pseudo-op. */
1648 s_err (int ignore ATTRIBUTE_UNUSED
)
1650 as_bad (_(".err encountered"));
1651 demand_empty_rest_of_line ();
1654 /* Handle the MRI fail pseudo-op. */
1657 s_fail (int ignore ATTRIBUTE_UNUSED
)
1664 stop
= mri_comment_field (&stopc
);
1666 temp
= get_absolute_expression ();
1668 as_warn (_(".fail %ld encountered"), (long) temp
);
1670 as_bad (_(".fail %ld encountered"), (long) temp
);
1672 demand_empty_rest_of_line ();
1675 mri_comment_end (stop
, stopc
);
1679 s_fill (int ignore ATTRIBUTE_UNUSED
)
1681 expressionS rep_exp
;
1683 register long fill
= 0;
1686 #ifdef md_flush_pending_output
1687 md_flush_pending_output ();
1690 get_known_segmented_expression (&rep_exp
);
1691 if (*input_line_pointer
== ',')
1693 input_line_pointer
++;
1694 size
= get_absolute_expression ();
1695 if (*input_line_pointer
== ',')
1697 input_line_pointer
++;
1698 fill
= get_absolute_expression ();
1702 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1703 #define BSD_FILL_SIZE_CROCK_8 (8)
1704 if (size
> BSD_FILL_SIZE_CROCK_8
)
1706 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
1707 size
= BSD_FILL_SIZE_CROCK_8
;
1711 as_warn (_("size negative; .fill ignored"));
1714 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1716 if (rep_exp
.X_add_number
< 0)
1717 as_warn (_("repeat < 0; .fill ignored"));
1721 if (size
&& !need_pass_2
)
1723 if (rep_exp
.X_op
== O_constant
)
1725 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1726 (relax_substateT
) 0, (symbolS
*) 0,
1727 (offsetT
) rep_exp
.X_add_number
,
1732 /* We don't have a constant repeat count, so we can't use
1733 rs_fill. We can get the same results out of rs_space,
1734 but its argument is in bytes, so we must multiply the
1735 repeat count by size. */
1738 rep_sym
= make_expr_symbol (&rep_exp
);
1741 expressionS size_exp
;
1742 size_exp
.X_op
= O_constant
;
1743 size_exp
.X_add_number
= size
;
1745 rep_exp
.X_op
= O_multiply
;
1746 rep_exp
.X_add_symbol
= rep_sym
;
1747 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1748 rep_exp
.X_add_number
= 0;
1749 rep_sym
= make_expr_symbol (&rep_exp
);
1752 p
= frag_var (rs_space
, (int) size
, (int) size
,
1753 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1756 memset (p
, 0, (unsigned int) size
);
1758 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1759 flavoured AS. The following bizarre behaviour is to be
1760 compatible with above. I guess they tried to take up to 8
1761 bytes from a 4-byte expression and they forgot to sign
1763 #define BSD_FILL_SIZE_CROCK_4 (4)
1764 md_number_to_chars (p
, (valueT
) fill
,
1765 (size
> BSD_FILL_SIZE_CROCK_4
1766 ? BSD_FILL_SIZE_CROCK_4
1768 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1769 but emits no error message because it seems a legal thing to do.
1770 It is a degenerate case of .fill but could be emitted by a
1773 demand_empty_rest_of_line ();
1777 s_globl (int ignore ATTRIBUTE_UNUSED
)
1786 stop
= mri_comment_field (&stopc
);
1790 name
= input_line_pointer
;
1791 c
= get_symbol_end ();
1792 symbolP
= symbol_find_or_make (name
);
1793 S_SET_EXTERNAL (symbolP
);
1795 *input_line_pointer
= c
;
1797 c
= *input_line_pointer
;
1800 input_line_pointer
++;
1802 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1808 demand_empty_rest_of_line ();
1811 mri_comment_end (stop
, stopc
);
1814 /* 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
);
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. */
1850 s_linkonce (int ignore ATTRIBUTE_UNUSED
)
1852 enum linkonce_type type
;
1856 type
= LINKONCE_DISCARD
;
1858 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1863 s
= input_line_pointer
;
1864 c
= get_symbol_end ();
1865 if (strcasecmp (s
, "discard") == 0)
1866 type
= LINKONCE_DISCARD
;
1867 else if (strcasecmp (s
, "one_only") == 0)
1868 type
= LINKONCE_ONE_ONLY
;
1869 else if (strcasecmp (s
, "same_size") == 0)
1870 type
= LINKONCE_SAME_SIZE
;
1871 else if (strcasecmp (s
, "same_contents") == 0)
1872 type
= LINKONCE_SAME_CONTENTS
;
1874 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1876 *input_line_pointer
= c
;
1879 #ifdef obj_handle_link_once
1880 obj_handle_link_once (type
);
1881 #else /* ! defined (obj_handle_link_once) */
1882 #ifdef BFD_ASSEMBLER
1886 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1887 as_warn (_(".linkonce is not supported for this object file format"));
1889 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1890 flags
|= SEC_LINK_ONCE
;
1895 case LINKONCE_DISCARD
:
1896 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1898 case LINKONCE_ONE_ONLY
:
1899 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1901 case LINKONCE_SAME_SIZE
:
1902 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1904 case LINKONCE_SAME_CONTENTS
:
1905 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1908 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1909 as_bad (_("bfd_set_section_flags: %s"),
1910 bfd_errmsg (bfd_get_error ()));
1912 #else /* ! defined (BFD_ASSEMBLER) */
1913 as_warn (_(".linkonce is not supported for this object file format"));
1914 #endif /* ! defined (BFD_ASSEMBLER) */
1915 #endif /* ! defined (obj_handle_link_once) */
1917 demand_empty_rest_of_line ();
1921 s_lcomm_internal (/* 1 if this was a ".bss" directive, which may
1922 require a 3rd argument (alignment); 0 if it was
1923 an ".lcomm" (2 args only). */
1925 /* 1 if the alignment value should be interpreted as
1926 the byte boundary, rather than the power of 2. */
1929 register char *name
;
1933 register symbolS
*symbolP
;
1934 segT current_seg
= now_seg
;
1935 subsegT current_subseg
= now_subseg
;
1936 const int max_alignment
= 15;
1938 segT bss_seg
= bss_section
;
1940 name
= input_line_pointer
;
1941 c
= get_symbol_end ();
1942 p
= input_line_pointer
;
1947 as_bad (_("expected symbol name"));
1948 discard_rest_of_line ();
1954 /* Accept an optional comma after the name. The comma used to be
1955 required, but Irix 5 cc does not generate it. */
1956 if (*input_line_pointer
== ',')
1958 ++input_line_pointer
;
1962 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1964 as_bad (_("missing size expression"));
1968 if ((temp
= get_absolute_expression ()) < 0)
1970 as_warn (_("BSS length (%d) < 0 ignored"), temp
);
1971 ignore_rest_of_line ();
1975 #if defined (TC_MIPS) || defined (TC_ALPHA)
1976 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1977 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1979 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1980 if ((unsigned) temp
<= bfd_get_gp_size (stdoutput
))
1982 bss_seg
= subseg_new (".sbss", 1);
1983 seg_info (bss_seg
)->bss
= 1;
1984 #ifdef BFD_ASSEMBLER
1985 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1986 as_warn (_("error setting flags for \".sbss\": %s"),
1987 bfd_errmsg (bfd_get_error ()));
1995 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
1997 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
1999 record_alignment (bss_seg
, align
);
2007 if (*input_line_pointer
!= ',')
2009 as_bad (_("expected comma after size"));
2010 ignore_rest_of_line ();
2014 input_line_pointer
++;
2017 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2019 as_bad (_("missing alignment"));
2023 align
= get_absolute_expression ();
2027 /* Convert to a power of 2. */
2032 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2035 as_bad (_("alignment not a power of 2"));
2040 if (align
> max_alignment
)
2042 align
= max_alignment
;
2043 as_warn (_("alignment too large; %d assumed"), align
);
2048 as_warn (_("alignment negative; 0 assumed"));
2051 record_alignment (bss_seg
, align
);
2055 /* Assume some objects may require alignment on some systems. */
2056 #if defined (TC_ALPHA) && ! defined (VMS)
2059 align
= ffs (temp
) - 1;
2060 if (temp
% (1 << align
))
2067 symbolP
= symbol_find_or_make (name
);
2071 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2072 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2073 #ifdef BFD_ASSEMBLER
2074 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2075 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2077 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2080 (S_GET_SEGMENT (symbolP
) == bss_seg
2081 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2085 subseg_set (bss_seg
, 1);
2088 frag_align (align
, 0, 0);
2090 /* Detach from old frag. */
2091 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2092 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2094 symbol_set_frag (symbolP
, frag_now
);
2095 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2096 (offsetT
) temp
, (char *) 0);
2099 S_SET_SEGMENT (symbolP
, bss_seg
);
2102 /* The symbol may already have been created with a preceding
2103 ".globl" directive -- be careful not to step on storage class
2104 in that case. Otherwise, set it to static. */
2105 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2107 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2109 #endif /* OBJ_COFF */
2112 S_SET_SIZE (symbolP
, temp
);
2116 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2118 subseg_set (current_seg
, current_subseg
);
2120 demand_empty_rest_of_line ();
2124 s_lcomm (int needs_align
)
2126 s_lcomm_internal (needs_align
, 0);
2130 s_lcomm_bytes (int needs_align
)
2132 s_lcomm_internal (needs_align
, 1);
2136 s_lsym (int ignore ATTRIBUTE_UNUSED
)
2138 register char *name
;
2142 register symbolS
*symbolP
;
2144 /* We permit ANY defined expression: BSD4.2 demands constants. */
2145 name
= input_line_pointer
;
2146 c
= get_symbol_end ();
2147 p
= input_line_pointer
;
2152 as_bad (_("expected symbol name"));
2153 discard_rest_of_line ();
2159 if (*input_line_pointer
!= ',')
2162 as_bad (_("expected comma after \"%s\""), name
);
2164 ignore_rest_of_line ();
2168 input_line_pointer
++;
2171 if (exp
.X_op
!= O_constant
2172 && exp
.X_op
!= O_register
)
2174 as_bad (_("bad expression"));
2175 ignore_rest_of_line ();
2180 symbolP
= symbol_find_or_make (name
);
2182 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2183 symbolP->sy_desc == 0) out of this test because coff doesn't have
2184 those fields, and I can't see when they'd ever be tripped. I
2185 don't think I understand why they were here so I may have
2186 introduced a bug. As recently as 1.37 didn't have this test
2187 anyway. xoxorich. */
2189 if (S_GET_SEGMENT (symbolP
) == undefined_section
2190 && S_GET_VALUE (symbolP
) == 0)
2192 /* The name might be an undefined .global symbol; be sure to
2193 keep the "external" bit. */
2194 S_SET_SEGMENT (symbolP
,
2195 (exp
.X_op
== O_constant
2198 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2202 as_bad (_("symbol `%s' is already defined"), name
);
2206 demand_empty_rest_of_line ();
2209 /* Read a line into an sb. Returns the character that ended the line
2210 or zero if there are no more lines. */
2213 get_line_sb (sb
*line
)
2215 char quote1
, quote2
, inquote
;
2218 if (input_line_pointer
[-1] == '\n')
2219 bump_line_counters ();
2221 if (input_line_pointer
>= buffer_limit
)
2223 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2224 if (buffer_limit
== 0)
2228 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2229 code needs to be changed. */
2238 #ifdef LEX_IS_STRINGQUOTE
2244 while ((c
= * input_line_pointer
++) != 0
2245 && (!is_end_of_line
[c
]
2246 || (inquote
!= '\0' && c
!= '\n')))
2250 else if (inquote
== '\0')
2254 else if (c
== quote2
)
2258 sb_add_char (line
, c
);
2261 /* Don't skip multiple end-of-line characters, because that breaks support
2262 for the IA-64 stop bit (;;) which looks like two consecutive end-of-line
2263 characters but isn't. Instead just skip one end of line character and
2264 return the character skipped so that the caller can re-insert it if
2269 /* Define a macro. This is an interface to macro.c. */
2272 s_macro (int ignore ATTRIBUTE_UNUSED
)
2281 as_where (&file
, &line
);
2284 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2285 sb_add_char (&s
, *input_line_pointer
++);
2288 if (line_label
!= NULL
)
2289 sb_add_string (&label
, S_GET_NAME (line_label
));
2291 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2293 as_bad_where (file
, line
, "%s", err
);
2296 if (line_label
!= NULL
)
2298 S_SET_SEGMENT (line_label
, undefined_section
);
2299 S_SET_VALUE (line_label
, 0);
2300 symbol_set_frag (line_label
, &zero_address_frag
);
2303 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2304 && hash_find (po_hash
, name
) != NULL
)
2307 && hash_find (po_hash
, name
+ 1) != NULL
))
2308 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2315 /* Handle the .mexit pseudo-op, which immediately exits a macro
2319 s_mexit (int ignore ATTRIBUTE_UNUSED
)
2321 cond_exit_macro (macro_nest
);
2322 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2325 /* Switch in and out of MRI mode. */
2328 s_mri (int ignore ATTRIBUTE_UNUSED
)
2332 on
= get_absolute_expression ();
2333 old_flag
= flag_mri
;
2351 /* Operator precedence changes in m68k MRI mode, so we need to
2352 update the operator rankings. */
2353 expr_set_precedence ();
2355 #ifdef MRI_MODE_CHANGE
2357 MRI_MODE_CHANGE (on
);
2360 demand_empty_rest_of_line ();
2363 /* Handle changing the location counter. */
2366 do_org (segT segment
, expressionS
*exp
, int fill
)
2368 if (segment
!= now_seg
&& segment
!= absolute_section
)
2369 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2371 if (now_seg
== absolute_section
)
2374 as_warn (_("ignoring fill value in absolute section"));
2375 if (exp
->X_op
!= O_constant
)
2377 as_bad (_("only constant offsets supported in absolute section"));
2378 exp
->X_add_number
= 0;
2380 abs_section_offset
= exp
->X_add_number
;
2385 symbolS
*sym
= exp
->X_add_symbol
;
2386 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2388 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2390 /* Handle complex expressions. */
2391 sym
= make_expr_symbol (exp
);
2395 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2401 s_org (int ignore ATTRIBUTE_UNUSED
)
2403 register segT segment
;
2405 register long temp_fill
;
2407 #ifdef md_flush_pending_output
2408 md_flush_pending_output ();
2411 /* The m68k MRI assembler has a different meaning for .org. It
2412 means to create an absolute section at a given address. We can't
2413 support that--use a linker script instead. */
2416 as_bad (_("MRI style ORG pseudo-op not supported"));
2417 ignore_rest_of_line ();
2421 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2422 thing as a sub-segment-relative origin. Any absolute origin is
2423 given a warning, then assumed to be segment-relative. Any
2424 segmented origin expression ("foo+42") had better be in the right
2425 segment or the .org is ignored.
2427 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2428 we never know sub-segment sizes when we are reading code. BSD
2429 will crash trying to emit negative numbers of filler bytes in
2430 certain .orgs. We don't crash, but see as-write for that code.
2432 Don't make frag if need_pass_2==1. */
2433 segment
= get_known_segmented_expression (&exp
);
2434 if (*input_line_pointer
== ',')
2436 input_line_pointer
++;
2437 temp_fill
= get_absolute_expression ();
2443 do_org (segment
, &exp
, temp_fill
);
2445 demand_empty_rest_of_line ();
2448 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2449 called by the obj-format routine which handles section changing
2450 when in MRI mode. It will create a new section, and return it. It
2451 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2452 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2453 flags will be set in the section. */
2456 s_mri_sect (char *type ATTRIBUTE_UNUSED
)
2466 name
= input_line_pointer
;
2467 if (!ISDIGIT (*name
))
2468 c
= get_symbol_end ();
2473 ++input_line_pointer
;
2475 while (ISDIGIT (*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
;
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. */
2620 s_print (int ignore ATTRIBUTE_UNUSED
)
2625 s
= demand_copy_C_string (&len
);
2628 demand_empty_rest_of_line ();
2631 /* Handle the .purgem pseudo-op. */
2634 s_purgem (int ignore ATTRIBUTE_UNUSED
)
2636 if (is_it_end_of_statement ())
2638 demand_empty_rest_of_line ();
2648 name
= input_line_pointer
;
2649 c
= get_symbol_end ();
2650 delete_macro (name
);
2651 *input_line_pointer
= c
;
2654 while (*input_line_pointer
++ == ',');
2656 --input_line_pointer
;
2657 demand_empty_rest_of_line ();
2660 /* Handle the .rept pseudo-op. */
2663 s_bad_endr (int ignore ATTRIBUTE_UNUSED
)
2665 as_warn (_(".endr encountered without preceeding .rept, .irc, or .irp"));
2666 demand_empty_rest_of_line ();
2669 /* Handle the .rept pseudo-op. */
2672 s_rept (int ignore ATTRIBUTE_UNUSED
)
2676 count
= get_absolute_expression ();
2678 do_repeat (count
, "REPT", "ENDR");
2681 /* This function provides a generic repeat block implementation. It allows
2682 different directives to be used as the start/end keys. */
2685 do_repeat (int count
, const char *start
, const char *end
)
2691 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2693 as_bad (_("%s without %s"), start
, end
);
2699 sb_add_sb (&many
, &one
);
2703 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2705 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2708 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2709 input buffers to skip. Assumes that conditionals preceding the loop end
2710 are properly nested.
2712 This function makes it easier to implement a premature "break" out of the
2713 loop. The EXTRA arg accounts for other buffers we might have inserted,
2714 such as line substitutions. */
2717 end_repeat (int extra
)
2719 cond_exit_macro (macro_nest
);
2720 while (extra
-- >= 0)
2721 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2724 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2725 this is .equiv, and it is an error if the symbol is already
2731 register char *name
;
2732 register char delim
;
2733 register char *end_name
;
2734 register symbolS
*symbolP
;
2736 /* Especial apologies for the random logic:
2737 this just grew, and could be parsed much more simply!
2739 name
= input_line_pointer
;
2740 delim
= get_symbol_end ();
2741 end_name
= input_line_pointer
;
2744 if (name
== end_name
)
2746 as_bad (_("expected symbol name"));
2747 discard_rest_of_line ();
2753 if (*input_line_pointer
!= ',')
2756 as_bad (_("expected comma after \"%s\""), name
);
2758 ignore_rest_of_line ();
2762 input_line_pointer
++;
2765 if (name
[0] == '.' && name
[1] == '\0')
2767 /* Turn '. = mumble' into a .org mumble. */
2768 register segT segment
;
2771 segment
= get_known_segmented_expression (&exp
);
2774 do_org (segment
, &exp
, 0);
2780 if ((symbolP
= symbol_find (name
)) == NULL
2781 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2784 /* When doing symbol listings, play games with dummy fragments living
2785 outside the normal fragment chain to record the file and line info
2787 if (listing
& LISTING_SYMBOLS
)
2789 extern struct list_info_struct
*listing_tail
;
2790 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2791 memset (dummy_frag
, 0, sizeof (fragS
));
2792 dummy_frag
->fr_type
= rs_fill
;
2793 dummy_frag
->line
= listing_tail
;
2794 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2795 dummy_frag
->fr_symbol
= symbolP
;
2799 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2802 /* "set" symbols are local unless otherwise specified. */
2803 SF_SET_LOCAL (symbolP
);
2804 #endif /* OBJ_COFF */
2807 symbol_table_insert (symbolP
);
2812 && S_IS_DEFINED (symbolP
)
2813 && S_GET_SEGMENT (symbolP
) != reg_section
)
2814 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2816 pseudo_set (symbolP
);
2817 demand_empty_rest_of_line ();
2830 #ifdef md_flush_pending_output
2831 md_flush_pending_output ();
2835 stop
= mri_comment_field (&stopc
);
2837 /* In m68k MRI mode, we need to align to a word boundary, unless
2839 if (flag_m68k_mri
&& mult
> 1)
2841 if (now_seg
== absolute_section
)
2843 abs_section_offset
+= abs_section_offset
& 1;
2844 if (line_label
!= NULL
)
2845 S_SET_VALUE (line_label
, abs_section_offset
);
2847 else if (mri_common_symbol
!= NULL
)
2851 val
= S_GET_VALUE (mri_common_symbol
);
2854 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2855 if (line_label
!= NULL
)
2857 expressionS
*symexp
;
2859 symexp
= symbol_get_value_expression (line_label
);
2860 know (symexp
->X_op
== O_symbol
);
2861 know (symexp
->X_add_symbol
== mri_common_symbol
);
2862 symexp
->X_add_number
+= 1;
2868 do_align (1, (char *) NULL
, 0, 0);
2869 if (line_label
!= NULL
)
2871 symbol_set_frag (line_label
, frag_now
);
2872 S_SET_VALUE (line_label
, frag_now_fix ());
2882 if (*input_line_pointer
== ',')
2884 ++input_line_pointer
;
2889 val
.X_op
= O_constant
;
2890 val
.X_add_number
= 0;
2893 if (val
.X_op
!= O_constant
2894 || val
.X_add_number
< - 0x80
2895 || val
.X_add_number
> 0xff
2896 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2898 if (exp
.X_op
!= O_constant
)
2899 as_bad (_("unsupported variable size or fill value"));
2906 bytes
= mult
* exp
.X_add_number
;
2907 for (i
= 0; i
< exp
.X_add_number
; i
++)
2908 emit_expr (&val
, mult
);
2913 if (exp
.X_op
== O_constant
)
2917 repeat
= exp
.X_add_number
;
2924 as_warn (_(".space repeat count is zero, ignored"));
2925 else if (repeat
< 0)
2926 as_warn (_(".space repeat count is negative, ignored"));
2930 /* If we are in the absolute section, just bump the offset. */
2931 if (now_seg
== absolute_section
)
2933 abs_section_offset
+= repeat
;
2937 /* If we are secretly in an MRI common section, then
2938 creating space just increases the size of the common
2940 if (mri_common_symbol
!= NULL
)
2942 S_SET_VALUE (mri_common_symbol
,
2943 S_GET_VALUE (mri_common_symbol
) + repeat
);
2948 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2949 (offsetT
) repeat
, (char *) 0);
2953 if (now_seg
== absolute_section
)
2955 as_bad (_("space allocation too complex in absolute section"));
2956 subseg_set (text_section
, 0);
2959 if (mri_common_symbol
!= NULL
)
2961 as_bad (_("space allocation too complex in common section"));
2962 mri_common_symbol
= NULL
;
2966 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2967 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2971 *p
= val
.X_add_number
;
2976 /* In MRI mode, after an odd number of bytes, we must align to an
2977 even word boundary, unless the next instruction is a dc.b, ds.b
2979 if (flag_mri
&& (bytes
& 1) != 0)
2980 mri_pending_align
= 1;
2982 demand_empty_rest_of_line ();
2985 mri_comment_end (stop
, stopc
);
2988 /* This is like s_space, but the value is a floating point number with
2989 the given precision. This is for the MRI dcb.s pseudo-op and
2993 s_float_space (int float_type
)
2997 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3002 stop
= mri_comment_field (&stopc
);
3004 count
= get_absolute_expression ();
3007 if (*input_line_pointer
!= ',')
3009 as_bad (_("missing value"));
3010 ignore_rest_of_line ();
3012 mri_comment_end (stop
, stopc
);
3016 ++input_line_pointer
;
3020 /* Skip any 0{letter} that may be present. Don't even check if the
3021 * letter is legal. */
3022 if (input_line_pointer
[0] == '0'
3023 && ISALPHA (input_line_pointer
[1]))
3024 input_line_pointer
+= 2;
3026 /* Accept :xxxx, where the x's are hex digits, for a floating point
3027 with the exact digits specified. */
3028 if (input_line_pointer
[0] == ':')
3030 flen
= hex_float (float_type
, temp
);
3033 ignore_rest_of_line ();
3035 mri_comment_end (stop
, stopc
);
3043 err
= md_atof (float_type
, temp
, &flen
);
3044 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3048 as_bad (_("bad floating literal: %s"), err
);
3049 ignore_rest_of_line ();
3051 mri_comment_end (stop
, stopc
);
3056 while (--count
>= 0)
3060 p
= frag_more (flen
);
3061 memcpy (p
, temp
, (unsigned int) flen
);
3064 demand_empty_rest_of_line ();
3067 mri_comment_end (stop
, stopc
);
3070 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3073 s_struct (int ignore ATTRIBUTE_UNUSED
)
3079 stop
= mri_comment_field (&stopc
);
3080 abs_section_offset
= get_absolute_expression ();
3081 subseg_set (absolute_section
, 0);
3082 demand_empty_rest_of_line ();
3084 mri_comment_end (stop
, stopc
);
3088 s_text (int ignore ATTRIBUTE_UNUSED
)
3092 temp
= get_absolute_expression ();
3093 subseg_set (text_section
, (subsegT
) temp
);
3094 demand_empty_rest_of_line ();
3096 const_flag
&= ~IN_DEFAULT_SECTION
;
3101 demand_empty_rest_of_line (void)
3104 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3105 input_line_pointer
++;
3107 ignore_rest_of_line ();
3109 /* Return having already swallowed end-of-line. */
3113 ignore_rest_of_line (void)
3115 /* For suspect lines: gives warning. */
3116 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3118 if (ISPRINT (*input_line_pointer
))
3119 as_warn (_("rest of line ignored; first ignored character is `%c'"),
3120 *input_line_pointer
);
3122 as_warn (_("rest of line ignored; first ignored character valued 0x%x"),
3123 *input_line_pointer
);
3125 while (input_line_pointer
< buffer_limit
3126 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3127 input_line_pointer
++;
3130 input_line_pointer
++;
3132 /* Return pointing just after end-of-line. */
3133 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3137 discard_rest_of_line (void)
3139 while (input_line_pointer
< buffer_limit
3140 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3141 input_line_pointer
++;
3143 input_line_pointer
++;
3145 /* Return pointing just after end-of-line. */
3146 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3149 /* In: Pointer to a symbol.
3150 Input_line_pointer->expression.
3152 Out: Input_line_pointer->just after any whitespace after expression.
3153 Tried to set symbol to value of expression.
3154 Will change symbols type, value, and frag; */
3157 pseudo_set (symbolS
*symbolP
)
3160 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3162 #endif /* OBJ_AOUT or OBJ_BOUT */
3164 know (symbolP
); /* NULL pointer is logic error. */
3165 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3166 ext
= S_IS_EXTERNAL (symbolP
);
3167 #endif /* OBJ_AOUT or OBJ_BOUT */
3169 (void) expression (&exp
);
3171 if (exp
.X_op
== O_illegal
)
3172 as_bad (_("illegal expression"));
3173 else if (exp
.X_op
== O_absent
)
3174 as_bad (_("missing expression"));
3175 else if (exp
.X_op
== O_big
)
3177 if (exp
.X_add_number
> 0)
3178 as_bad (_("bignum invalid"));
3180 as_bad (_("floating point number invalid"));
3182 else if (exp
.X_op
== O_subtract
3183 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3184 && (symbol_get_frag (exp
.X_add_symbol
)
3185 == symbol_get_frag (exp
.X_op_symbol
)))
3187 exp
.X_op
= O_constant
;
3188 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3189 - S_GET_VALUE (exp
.X_op_symbol
));
3197 exp
.X_add_number
= 0;
3200 S_SET_SEGMENT (symbolP
, absolute_section
);
3201 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3203 S_SET_EXTERNAL (symbolP
);
3205 S_CLEAR_EXTERNAL (symbolP
);
3206 #endif /* OBJ_AOUT or OBJ_BOUT */
3207 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3208 if (exp
.X_op
!= O_constant
)
3209 symbol_set_frag (symbolP
, &zero_address_frag
);
3213 S_SET_SEGMENT (symbolP
, reg_section
);
3214 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3215 symbol_set_frag (symbolP
, &zero_address_frag
);
3219 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3220 || exp
.X_add_number
!= 0)
3221 symbol_set_value_expression (symbolP
, &exp
);
3222 else if (symbol_section_p (symbolP
))
3223 as_bad ("attempt to set value of section symbol");
3226 symbolS
*s
= exp
.X_add_symbol
;
3228 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3229 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3231 S_SET_EXTERNAL (symbolP
);
3233 S_CLEAR_EXTERNAL (symbolP
);
3234 #endif /* OBJ_AOUT or OBJ_BOUT */
3235 S_SET_VALUE (symbolP
,
3236 exp
.X_add_number
+ S_GET_VALUE (s
));
3237 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3238 copy_symbol_attributes (symbolP
, s
);
3243 /* The value is some complex expression.
3244 FIXME: Should we set the segment to anything? */
3245 symbol_set_value_expression (symbolP
, &exp
);
3252 CONStruct more frag of .bytes, or .words etc.
3253 Should need_pass_2 be 1 then emit no frag(s).
3254 This understands EXPRESSIONS.
3258 This has a split personality. We use expression() to read the
3259 value. We can detect if the value won't fit in a byte or word.
3260 But we can't detect if expression() discarded significant digits
3261 in the case of a long. Not worth the crocks required to fix it. */
3263 /* Select a parser for cons expressions. */
3265 /* Some targets need to parse the expression in various fancy ways.
3266 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3267 (for example, the HPPA does this). Otherwise, you can define
3268 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3269 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3270 are defined, which is the normal case, then only simple expressions
3275 parse_mri_cons (expressionS
*exp
, unsigned int nbytes
);
3278 #ifndef TC_PARSE_CONS_EXPRESSION
3279 #ifdef BITFIELD_CONS_EXPRESSIONS
3280 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3282 parse_bitfield_cons (expressionS
*exp
, unsigned int nbytes
);
3284 #ifdef REPEAT_CONS_EXPRESSIONS
3285 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3287 parse_repeat_cons (expressionS
*exp
, unsigned int nbytes
);
3290 /* If we haven't gotten one yet, just call expression. */
3291 #ifndef TC_PARSE_CONS_EXPRESSION
3292 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3297 do_parse_cons_expression (expressionS
*exp
,
3298 int nbytes ATTRIBUTE_UNUSED
)
3300 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3304 /* Worker to do .byte etc statements.
3305 Clobbers input_line_pointer and checks end-of-line. */
3308 cons_worker (register int nbytes
, /* 1=.byte, 2=.word, 4=.long. */
3316 #ifdef md_flush_pending_output
3317 md_flush_pending_output ();
3321 stop
= mri_comment_field (&stopc
);
3323 if (is_it_end_of_statement ())
3325 demand_empty_rest_of_line ();
3327 mri_comment_end (stop
, stopc
);
3331 #ifdef md_cons_align
3332 md_cons_align (nbytes
);
3340 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3343 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3347 if (exp
.X_op
== O_symbol
)
3348 exp
.X_op
= O_symbol_rva
;
3350 as_fatal (_("rva without symbol"));
3352 emit_expr (&exp
, (unsigned int) nbytes
);
3355 while (*input_line_pointer
++ == ',');
3357 /* In MRI mode, after an odd number of bytes, we must align to an
3358 even word boundary, unless the next instruction is a dc.b, ds.b
3360 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3361 mri_pending_align
= 1;
3363 input_line_pointer
--; /* Put terminator back into stream. */
3365 demand_empty_rest_of_line ();
3368 mri_comment_end (stop
, stopc
);
3374 cons_worker (size
, 0);
3380 cons_worker (size
, 1);
3383 /* Put the contents of expression EXP into the object file using
3384 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3387 emit_expr (expressionS
*exp
, unsigned int nbytes
)
3391 valueT extra_digit
= 0;
3393 /* Don't do anything if we are going to make another pass. */
3397 dot_value
= frag_now_fix ();
3401 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3402 appear as a four byte positive constant in the .line section,
3403 followed by a 2 byte 0xffff. Look for that case here. */
3405 static int dwarf_line
= -1;
3407 if (strcmp (segment_name (now_seg
), ".line") != 0)
3409 else if (dwarf_line
>= 0
3411 && exp
->X_op
== O_constant
3412 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3413 listing_source_line ((unsigned int) dwarf_line
);
3414 else if (nbytes
== 4
3415 && exp
->X_op
== O_constant
3416 && exp
->X_add_number
>= 0)
3417 dwarf_line
= exp
->X_add_number
;
3422 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3423 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3424 AT_sibling (0x12) followed by a four byte address of the sibling
3425 followed by a 2 byte AT_name (0x38) followed by the name of the
3426 file. We look for that case here. */
3428 static int dwarf_file
= 0;
3430 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3432 else if (dwarf_file
== 0
3434 && exp
->X_op
== O_constant
3435 && exp
->X_add_number
== 0x11)
3437 else if (dwarf_file
== 1
3439 && exp
->X_op
== O_constant
3440 && exp
->X_add_number
== 0x12)
3442 else if (dwarf_file
== 2
3445 else if (dwarf_file
== 3
3447 && exp
->X_op
== O_constant
3448 && exp
->X_add_number
== 0x38)
3453 /* The variable dwarf_file_string tells stringer that the string
3454 may be the name of the source file. */
3455 if (dwarf_file
== 4)
3456 dwarf_file_string
= 1;
3458 dwarf_file_string
= 0;
3463 if (check_eh_frame (exp
, &nbytes
))
3468 /* Allow `.word 0' in the absolute section. */
3469 if (now_seg
== absolute_section
)
3471 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3472 as_bad (_("attempt to store value in absolute section"));
3473 abs_section_offset
+= nbytes
;
3477 /* Handle a negative bignum. */
3479 && exp
->X_add_number
== 0
3480 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3481 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3484 unsigned long carry
;
3486 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3488 /* Negate the bignum: one's complement each digit and add 1. */
3490 for (i
= 0; i
< exp
->X_add_number
; i
++)
3494 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3497 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3498 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3501 /* We can ignore any carry out, because it will be handled by
3502 extra_digit if it is needed. */
3504 extra_digit
= (valueT
) -1;
3508 if (op
== O_absent
|| op
== O_illegal
)
3510 as_warn (_("zero assumed for missing expression"));
3511 exp
->X_add_number
= 0;
3514 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3516 as_bad (_("floating point number invalid"));
3517 exp
->X_add_number
= 0;
3520 else if (op
== O_register
)
3522 as_warn (_("register value used as expression"));
3526 p
= frag_more ((int) nbytes
);
3528 #ifndef WORKING_DOT_WORD
3529 /* If we have the difference of two symbols in a word, save it on
3530 the broken_words list. See the code in write.c. */
3531 if (op
== O_subtract
&& nbytes
== 2)
3533 struct broken_word
*x
;
3535 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3536 x
->next_broken_word
= broken_words
;
3539 x
->subseg
= now_subseg
;
3541 x
->word_goes_here
= p
;
3543 x
->add
= exp
->X_add_symbol
;
3544 x
->sub
= exp
->X_op_symbol
;
3545 x
->addnum
= exp
->X_add_number
;
3553 /* If we have an integer, but the number of bytes is too large to
3554 pass to md_number_to_chars, handle it as a bignum. */
3555 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3560 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3561 extra_digit
= (valueT
) -1;
3562 val
= (valueT
) exp
->X_add_number
;
3566 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3567 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3571 op
= exp
->X_op
= O_big
;
3572 exp
->X_add_number
= gencnt
;
3575 if (op
== O_constant
)
3577 register valueT get
;
3578 register valueT use
;
3579 register valueT mask
;
3581 register valueT unmask
;
3583 /* JF << of >= number of bits in the object is undefined. In
3584 particular SPARC (Sun 4) has problems. */
3585 if (nbytes
>= sizeof (valueT
))
3588 if (nbytes
> sizeof (valueT
))
3591 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3595 /* Don't store these bits. */
3596 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3597 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3600 unmask
= ~mask
; /* Do store these bits. */
3603 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3604 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3607 get
= exp
->X_add_number
;
3609 if ((get
& mask
) != 0
3610 && ((get
& mask
) != mask
3611 || (get
& hibit
) == 0))
3612 { /* Leading bits contain both 0s & 1s. */
3613 as_warn (_("value 0x%lx truncated to 0x%lx"),
3614 (unsigned long) get
, (unsigned long) use
);
3616 /* Put bytes in right order. */
3617 md_number_to_chars (p
, use
, (int) nbytes
);
3619 else if (op
== O_big
)
3622 LITTLENUM_TYPE
*nums
;
3624 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3626 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3629 as_warn (_("bignum truncated to %d bytes"), nbytes
);
3633 if (target_big_endian
)
3635 while (nbytes
> size
)
3637 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3638 nbytes
-= CHARS_PER_LITTLENUM
;
3639 p
+= CHARS_PER_LITTLENUM
;
3642 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3643 while (size
>= CHARS_PER_LITTLENUM
)
3646 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3647 size
-= CHARS_PER_LITTLENUM
;
3648 p
+= CHARS_PER_LITTLENUM
;
3653 nums
= generic_bignum
;
3654 while (size
>= CHARS_PER_LITTLENUM
)
3656 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3658 size
-= CHARS_PER_LITTLENUM
;
3659 p
+= CHARS_PER_LITTLENUM
;
3660 nbytes
-= CHARS_PER_LITTLENUM
;
3663 while (nbytes
>= CHARS_PER_LITTLENUM
)
3665 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3666 nbytes
-= CHARS_PER_LITTLENUM
;
3667 p
+= CHARS_PER_LITTLENUM
;
3673 memset (p
, 0, nbytes
);
3675 /* Now we need to generate a fixS to record the symbol value.
3676 This is easy for BFD. For other targets it can be more
3677 complex. For very complex cases (currently, the HPPA and
3678 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3679 want. For simpler cases, you can define TC_CONS_RELOC to be
3680 the name of the reloc code that should be stored in the fixS.
3681 If neither is defined, the code uses NO_RELOC if it is
3682 defined, and otherwise uses 0. */
3684 #ifdef BFD_ASSEMBLER
3685 #ifdef TC_CONS_FIX_NEW
3686 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3689 bfd_reloc_code_real_type r
;
3706 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3710 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3715 #ifdef TC_CONS_FIX_NEW
3716 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3718 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3719 it is defined, otherwise use NO_RELOC if it is defined,
3721 #ifndef TC_CONS_RELOC
3723 #define TC_CONS_RELOC NO_RELOC
3725 #define TC_CONS_RELOC 0
3728 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3730 #endif /* TC_CONS_FIX_NEW */
3731 #endif /* BFD_ASSEMBLER */
3735 #ifdef BITFIELD_CONS_EXPRESSIONS
3737 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3738 w:x,y:z, where w and y are bitwidths and x and y are values. They
3739 then pack them all together. We do a little better in that we allow
3740 them in words, longs, etc. and we'll pack them in target byte order
3743 The rules are: pack least significant bit first, if a field doesn't
3744 entirely fit, put it in the next unit. Overflowing the bitfield is
3745 explicitly *not* even a warning. The bitwidth should be considered
3748 To use this function the tc-XXX.h file should define
3749 BITFIELD_CONS_EXPRESSIONS. */
3752 parse_bitfield_cons (exp
, nbytes
)
3754 unsigned int nbytes
;
3756 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3757 char *hold
= input_line_pointer
;
3759 (void) expression (exp
);
3761 if (*input_line_pointer
== ':')
3768 unsigned long width
;
3770 if (*input_line_pointer
!= ':')
3772 input_line_pointer
= hold
;
3774 } /* Next piece is not a bitfield. */
3776 /* In the general case, we can't allow
3777 full expressions with symbol
3778 differences and such. The relocation
3779 entries for symbols not defined in this
3780 assembly would require arbitrary field
3781 widths, positions, and masks which most
3782 of our current object formats don't
3785 In the specific case where a symbol
3786 *is* defined in this assembly, we
3787 *could* build fixups and track it, but
3788 this could lead to confusion for the
3789 backends. I'm lazy. I'll take any
3790 SEG_ABSOLUTE. I think that means that
3791 you can use a previous .set or
3792 .equ type symbol. xoxorich. */
3794 if (exp
->X_op
== O_absent
)
3796 as_warn (_("using a bit field width of zero"));
3797 exp
->X_add_number
= 0;
3798 exp
->X_op
= O_constant
;
3799 } /* Implied zero width bitfield. */
3801 if (exp
->X_op
!= O_constant
)
3803 *input_line_pointer
= '\0';
3804 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3805 *input_line_pointer
= ':';
3806 demand_empty_rest_of_line ();
3808 } /* Too complex. */
3810 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3812 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3813 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3814 width
= BITS_PER_CHAR
* nbytes
;
3817 if (width
> bits_available
)
3819 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3820 input_line_pointer
= hold
;
3821 exp
->X_add_number
= value
;
3826 hold
= ++input_line_pointer
;
3828 (void) expression (exp
);
3829 if (exp
->X_op
!= O_constant
)
3831 char cache
= *input_line_pointer
;
3833 *input_line_pointer
= '\0';
3834 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3835 *input_line_pointer
= cache
;
3836 demand_empty_rest_of_line ();
3838 } /* Too complex. */
3840 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3841 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3843 if ((bits_available
-= width
) == 0
3844 || is_it_end_of_statement ()
3845 || *input_line_pointer
!= ',')
3848 } /* All the bitfields we're gonna get. */
3850 hold
= ++input_line_pointer
;
3851 (void) expression (exp
);
3854 exp
->X_add_number
= value
;
3855 exp
->X_op
= O_constant
;
3856 exp
->X_unsigned
= 1;
3860 #endif /* BITFIELD_CONS_EXPRESSIONS */
3862 /* Handle an MRI style string expression. */
3866 parse_mri_cons (exp
, nbytes
)
3868 unsigned int nbytes
;
3870 if (*input_line_pointer
!= '\''
3871 && (input_line_pointer
[1] != '\''
3872 || (*input_line_pointer
!= 'A'
3873 && *input_line_pointer
!= 'E')))
3874 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3878 unsigned int result
= 0;
3880 /* An MRI style string. Cut into as many bytes as will fit into
3881 a nbyte chunk, left justify if necessary, and separate with
3882 commas so we can try again later. */
3883 if (*input_line_pointer
== 'A')
3884 ++input_line_pointer
;
3885 else if (*input_line_pointer
== 'E')
3887 as_bad (_("EBCDIC constants are not supported"));
3888 ++input_line_pointer
;
3891 input_line_pointer
++;
3892 for (scan
= 0; scan
< nbytes
; scan
++)
3894 if (*input_line_pointer
== '\'')
3896 if (input_line_pointer
[1] == '\'')
3898 input_line_pointer
++;
3903 result
= (result
<< 8) | (*input_line_pointer
++);
3907 while (scan
< nbytes
)
3913 /* Create correct expression. */
3914 exp
->X_op
= O_constant
;
3915 exp
->X_add_number
= result
;
3917 /* Fake it so that we can read the next char too. */
3918 if (input_line_pointer
[0] != '\'' ||
3919 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3921 input_line_pointer
-= 2;
3922 input_line_pointer
[0] = ',';
3923 input_line_pointer
[1] = '\'';
3926 input_line_pointer
++;
3929 #endif /* TC_M68K */
3931 #ifdef REPEAT_CONS_EXPRESSIONS
3933 /* Parse a repeat expression for cons. This is used by the MIPS
3934 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3935 object file COUNT times.
3937 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3940 parse_repeat_cons (exp
, nbytes
)
3942 unsigned int nbytes
;
3949 if (*input_line_pointer
!= ':')
3951 /* No repeat count. */
3955 ++input_line_pointer
;
3956 expression (&count
);
3957 if (count
.X_op
!= O_constant
3958 || count
.X_add_number
<= 0)
3960 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
3964 /* The cons function is going to output this expression once. So we
3965 output it count - 1 times. */
3966 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3967 emit_expr (exp
, nbytes
);
3970 #endif /* REPEAT_CONS_EXPRESSIONS */
3972 /* Parse a floating point number represented as a hex constant. This
3973 permits users to specify the exact bits they want in the floating
3977 hex_float (int float_type
, char *bytes
)
4009 as_bad (_("unknown floating type type '%c'"), float_type
);
4013 /* It would be nice if we could go through expression to parse the
4014 hex constant, but if we get a bignum it's a pain to sort it into
4015 the buffer correctly. */
4017 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4021 /* The MRI assembler accepts arbitrary underscores strewn about
4022 through the hex constant, so we ignore them as well. */
4023 if (*input_line_pointer
== '_')
4025 ++input_line_pointer
;
4031 as_warn (_("floating point constant too large"));
4034 d
= hex_value (*input_line_pointer
) << 4;
4035 ++input_line_pointer
;
4036 while (*input_line_pointer
== '_')
4037 ++input_line_pointer
;
4038 if (hex_p (*input_line_pointer
))
4040 d
+= hex_value (*input_line_pointer
);
4041 ++input_line_pointer
;
4043 if (target_big_endian
)
4046 bytes
[length
- i
- 1] = d
;
4052 if (target_big_endian
)
4053 memset (bytes
+ i
, 0, length
- i
);
4055 memset (bytes
, 0, length
- i
);
4063 CONStruct some more frag chars of .floats .ffloats etc.
4064 Makes 0 or more new frags.
4065 If need_pass_2 == 1, no frags are emitted.
4066 This understands only floating literals, not expressions. Sorry.
4068 A floating constant is defined by atof_generic(), except it is preceded
4069 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4070 reading, I decided to be incompatible. This always tries to give you
4071 rounded bits to the precision of the pseudo-op. Former AS did premature
4072 truncation, restored noisy bits instead of trailing 0s AND gave you
4073 a choice of 2 flavours of noise according to which of 2 floating-point
4074 scanners you directed AS to use.
4076 In: input_line_pointer->whitespace before, or '0' of flonum. */
4079 float_cons (/* Clobbers input_line-pointer, checks end-of-line. */
4080 register int float_type
/* 'f':.ffloat ... 'F':.float ... */)
4083 int length
; /* Number of chars in an object. */
4084 register char *err
; /* Error from scanning floating literal. */
4085 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4087 if (is_it_end_of_statement ())
4089 demand_empty_rest_of_line ();
4093 #ifdef md_flush_pending_output
4094 md_flush_pending_output ();
4099 /* input_line_pointer->1st char of a flonum (we hope!). */
4102 /* Skip any 0{letter} that may be present. Don't even check if the
4103 letter is legal. Someone may invent a "z" format and this routine
4104 has no use for such information. Lusers beware: you get
4105 diagnostics if your input is ill-conditioned. */
4106 if (input_line_pointer
[0] == '0'
4107 && ISALPHA (input_line_pointer
[1]))
4108 input_line_pointer
+= 2;
4110 /* Accept :xxxx, where the x's are hex digits, for a floating
4111 point with the exact digits specified. */
4112 if (input_line_pointer
[0] == ':')
4114 ++input_line_pointer
;
4115 length
= hex_float (float_type
, temp
);
4118 ignore_rest_of_line ();
4124 err
= md_atof (float_type
, temp
, &length
);
4125 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4129 as_bad (_("bad floating literal: %s"), err
);
4130 ignore_rest_of_line ();
4141 #ifdef REPEAT_CONS_EXPRESSIONS
4142 if (*input_line_pointer
== ':')
4144 expressionS count_exp
;
4146 ++input_line_pointer
;
4147 expression (&count_exp
);
4149 if (count_exp
.X_op
!= O_constant
4150 || count_exp
.X_add_number
<= 0)
4151 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4153 count
= count_exp
.X_add_number
;
4157 while (--count
>= 0)
4159 p
= frag_more (length
);
4160 memcpy (p
, temp
, (unsigned int) length
);
4165 while (*input_line_pointer
++ == ',');
4167 /* Put terminator back into stream. */
4168 --input_line_pointer
;
4169 demand_empty_rest_of_line ();
4172 /* Return the size of a LEB128 value. */
4175 sizeof_sleb128 (offsetT value
)
4177 register int size
= 0;
4178 register unsigned byte
;
4182 byte
= (value
& 0x7f);
4183 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4184 Fortunately, we can structure things so that the extra work reduces
4185 to a noop on systems that do things "properly". */
4186 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4189 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4190 || ((value
== -1) && ((byte
& 0x40) != 0))));
4196 sizeof_uleb128 (valueT value
)
4198 register int size
= 0;
4199 register unsigned byte
;
4203 byte
= (value
& 0x7f);
4213 sizeof_leb128 (valueT value
, int sign
)
4216 return sizeof_sleb128 ((offsetT
) value
);
4218 return sizeof_uleb128 (value
);
4221 /* Output a LEB128 value. */
4224 output_sleb128 (char *p
, offsetT 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 (char *p
, valueT value
)
4257 unsigned byte
= (value
& 0x7f);
4260 /* More bytes to follow. */
4271 output_leb128 (char *p
, valueT value
, int sign
)
4274 return output_sleb128 (p
, (offsetT
) value
);
4276 return output_uleb128 (p
, value
);
4279 /* Do the same for bignums. We combine sizeof with output here in that
4280 we don't output for NULL values of P. It isn't really as critical as
4281 for "normal" values that this be streamlined. */
4284 output_big_sleb128 (char *p
, LITTLENUM_TYPE
*bignum
, int size
)
4291 /* Strip leading sign extensions off the bignum. */
4292 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4297 if (loaded
< 7 && size
> 0)
4299 val
|= (*bignum
<< loaded
);
4300 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4311 if ((val
== 0 && (byte
& 0x40) == 0)
4312 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4313 && (byte
& 0x40) != 0))
4321 while (byte
& 0x80);
4327 output_big_uleb128 (char *p
, LITTLENUM_TYPE
*bignum
, int size
)
4334 /* Strip leading zeros off the bignum. */
4335 /* XXX: Is this needed? */
4336 while (size
> 0 && bignum
[size
- 1] == 0)
4341 if (loaded
< 7 && size
> 0)
4343 val
|= (*bignum
<< loaded
);
4344 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4353 if (size
> 0 || val
)
4360 while (byte
& 0x80);
4366 output_big_leb128 (char *p
, LITTLENUM_TYPE
*bignum
, int size
, int sign
)
4369 return output_big_sleb128 (p
, bignum
, size
);
4371 return output_big_uleb128 (p
, bignum
, size
);
4374 /* Generate the appropriate fragments for a given expression to emit a
4378 emit_leb128_expr (expressionS
*exp
, int sign
)
4380 operatorT op
= exp
->X_op
;
4383 if (op
== O_absent
|| op
== O_illegal
)
4385 as_warn (_("zero assumed for missing expression"));
4386 exp
->X_add_number
= 0;
4389 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4391 as_bad (_("floating point number invalid"));
4392 exp
->X_add_number
= 0;
4395 else if (op
== O_register
)
4397 as_warn (_("register value used as expression"));
4401 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
4402 a signal that this is leb128 data. It shouldn't optimize this away. */
4404 if (check_eh_frame (exp
, &nbytes
))
4407 /* Let the backend know that subsequent data may be byte aligned. */
4408 #ifdef md_cons_align
4412 if (op
== O_constant
)
4414 /* If we've got a constant, emit the thing directly right now. */
4416 valueT value
= exp
->X_add_number
;
4420 size
= sizeof_leb128 (value
, sign
);
4421 p
= frag_more (size
);
4422 output_leb128 (p
, value
, sign
);
4424 else if (op
== O_big
)
4426 /* O_big is a different sort of constant. */
4431 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4432 p
= frag_more (size
);
4433 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4437 /* Otherwise, we have to create a variable sized fragment and
4438 resolve things later. */
4440 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4441 make_expr_symbol (exp
), 0, (char *) NULL
);
4445 /* Parse the .sleb128 and .uleb128 pseudos. */
4455 emit_leb128_expr (&exp
, sign
);
4457 while (*input_line_pointer
++ == ',');
4459 input_line_pointer
--;
4460 demand_empty_rest_of_line ();
4463 /* We read 0 or more ',' separated, double-quoted strings.
4464 Caller should have checked need_pass_2 is FALSE because we don't
4468 stringer (/* Worker to do .ascii etc statements. */
4469 /* Checks end-of-line. */
4470 register int append_zero
/* 0: don't append '\0', else 1. */)
4472 register unsigned int c
;
4475 #ifdef md_flush_pending_output
4476 md_flush_pending_output ();
4479 /* The following awkward logic is to parse ZERO or more strings,
4480 comma separated. Recall a string expression includes spaces
4481 before the opening '\"' and spaces after the closing '\"'.
4482 We fake a leading ',' if there is (supposed to be)
4483 a 1st, expression. We keep demanding expressions for each ','. */
4484 if (is_it_end_of_statement ())
4486 c
= 0; /* Skip loop. */
4487 ++input_line_pointer
; /* Compensate for end of loop. */
4491 c
= ','; /* Do loop. */
4493 /* If we have been switched into the abs_section then we
4494 will not have an obstack onto which we can hang strings. */
4495 if (now_seg
== absolute_section
)
4497 as_bad (_("strings must be placed into a section"));
4499 ignore_rest_of_line ();
4502 while (c
== ',' || c
== '<' || c
== '"')
4505 switch (*input_line_pointer
)
4508 ++input_line_pointer
; /*->1st char of string. */
4509 start
= input_line_pointer
;
4510 while (is_a_char (c
= next_char_of_string ()))
4512 FRAG_APPEND_1_CHAR (c
);
4516 FRAG_APPEND_1_CHAR (0);
4518 know (input_line_pointer
[-1] == '\"');
4522 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4523 will emit .string with a filename in the .debug section
4524 after a sequence of constants. See the comment in
4525 emit_expr for the sequence. emit_expr will set
4526 dwarf_file_string to non-zero if this string might be a
4527 source file name. */
4528 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4529 dwarf_file_string
= 0;
4530 else if (dwarf_file_string
)
4532 c
= input_line_pointer
[-1];
4533 input_line_pointer
[-1] = '\0';
4534 listing_source_file (start
);
4535 input_line_pointer
[-1] = c
;
4542 input_line_pointer
++;
4543 c
= get_single_number ();
4544 FRAG_APPEND_1_CHAR (c
);
4545 if (*input_line_pointer
!= '>')
4547 as_bad (_("expected <nn>"));
4549 input_line_pointer
++;
4552 input_line_pointer
++;
4556 c
= *input_line_pointer
;
4559 demand_empty_rest_of_line ();
4562 /* FIXME-SOMEDAY: I had trouble here on characters with the
4563 high bits set. We'll probably also have trouble with
4564 multibyte chars, wide chars, etc. Also be careful about
4565 returning values bigger than 1 byte. xoxorich. */
4568 next_char_of_string (void)
4570 register unsigned int c
;
4572 c
= *input_line_pointer
++ & CHAR_MASK
;
4580 as_warn (_("unterminated string; newline inserted"));
4581 bump_line_counters ();
4584 #ifndef NO_STRING_ESCAPES
4586 switch (c
= *input_line_pointer
++)
4614 break; /* As itself. */
4630 for (i
= 0, number
= 0;
4631 ISDIGIT (c
) && i
< 3;
4632 c
= *input_line_pointer
++, i
++)
4634 number
= number
* 8 + c
- '0';
4639 --input_line_pointer
;
4648 c
= *input_line_pointer
++;
4649 while (ISXDIGIT (c
))
4652 number
= number
* 16 + c
- '0';
4653 else if (ISUPPER (c
))
4654 number
= number
* 16 + c
- 'A' + 10;
4656 number
= number
* 16 + c
- 'a' + 10;
4657 c
= *input_line_pointer
++;
4660 --input_line_pointer
;
4665 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4666 as_warn (_("unterminated string; newline inserted"));
4668 bump_line_counters ();
4673 #ifdef ONLY_STANDARD_ESCAPES
4674 as_bad (_("bad escaped character in string"));
4676 #endif /* ONLY_STANDARD_ESCAPES */
4681 #endif /* ! defined (NO_STRING_ESCAPES) */
4690 get_segmented_expression (register expressionS
*expP
)
4692 register segT retval
;
4694 retval
= expression (expP
);
4695 if (expP
->X_op
== O_illegal
4696 || expP
->X_op
== O_absent
4697 || expP
->X_op
== O_big
)
4699 as_bad (_("expected address expression"));
4700 expP
->X_op
= O_constant
;
4701 expP
->X_add_number
= 0;
4702 retval
= absolute_section
;
4708 get_known_segmented_expression (register expressionS
*expP
)
4710 register segT retval
;
4712 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4714 /* There is no easy way to extract the undefined symbol from the
4716 if (expP
->X_add_symbol
!= NULL
4717 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4718 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4719 S_GET_NAME (expP
->X_add_symbol
));
4721 as_warn (_("some symbol undefined; zero assumed"));
4722 retval
= absolute_section
;
4723 expP
->X_op
= O_constant
;
4724 expP
->X_add_number
= 0;
4726 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4731 get_absolute_expr (expressionS
*exp
)
4734 if (exp
->X_op
!= O_constant
)
4736 if (exp
->X_op
!= O_absent
)
4737 as_bad (_("bad or irreducible absolute expression"));
4738 exp
->X_add_number
= 0;
4740 return exp
->X_add_number
;
4744 get_absolute_expression (void)
4748 return get_absolute_expr (&exp
);
4751 char /* Return terminator. */
4752 get_absolute_expression_and_terminator (long *val_pointer
/* Return value of expression. */)
4754 /* FIXME: val_pointer should probably be offsetT *. */
4755 *val_pointer
= (long) get_absolute_expression ();
4756 return (*input_line_pointer
++);
4759 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4760 Give a warning if that happens. */
4763 demand_copy_C_string (int *len_pointer
)
4767 if ((s
= demand_copy_string (len_pointer
)) != 0)
4771 for (len
= *len_pointer
; len
> 0; len
--)
4778 as_bad (_("this string may not contain \'\\0\'"));
4786 /* Demand string, but return a safe (=private) copy of the string.
4787 Return NULL if we can't read a string here. */
4790 demand_copy_string (int *lenP
)
4792 register unsigned int c
;
4798 if (*input_line_pointer
== '\"')
4800 input_line_pointer
++; /* Skip opening quote. */
4802 while (is_a_char (c
= next_char_of_string ()))
4804 obstack_1grow (¬es
, c
);
4807 /* JF this next line is so demand_copy_C_string will return a
4808 null terminated string. */
4809 obstack_1grow (¬es
, '\0');
4810 retval
= obstack_finish (¬es
);
4814 as_warn (_("missing string"));
4816 ignore_rest_of_line ();
4822 /* In: Input_line_pointer->next character.
4824 Do: Skip input_line_pointer over all whitespace.
4826 Out: 1 if input_line_pointer->end-of-line. */
4829 is_it_end_of_statement (void)
4832 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4836 equals (char *sym_name
, int reassign
)
4838 register symbolS
*symbolP
; /* Symbol we are working with. */
4842 input_line_pointer
++;
4843 if (*input_line_pointer
== '=')
4844 input_line_pointer
++;
4846 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4847 input_line_pointer
++;
4850 stop
= mri_comment_field (&stopc
);
4852 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4854 /* Turn '. = mumble' into a .org mumble. */
4855 register segT segment
;
4858 segment
= get_known_segmented_expression (&exp
);
4860 do_org (segment
, &exp
, 0);
4867 symbolP
= symbol_find (sym_name
);
4868 local
= symbolP
== NULL
;
4870 #endif /* OBJ_COFF */
4871 symbolP
= symbol_find_or_make (sym_name
);
4872 /* Permit register names to be redefined. */
4874 && S_IS_DEFINED (symbolP
)
4875 && S_GET_SEGMENT (symbolP
) != reg_section
)
4876 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
4879 /* "set" symbols are local unless otherwise specified. */
4881 SF_SET_LOCAL (symbolP
);
4882 #endif /* OBJ_COFF */
4884 pseudo_set (symbolP
);
4889 /* Check garbage after the expression. */
4890 ignore_rest_of_line ();
4891 mri_comment_end (stop
, stopc
);
4895 /* .incbin -- include a file verbatim at the current location. */
4898 s_incbin (int x ATTRIBUTE_UNUSED
)
4909 #ifdef md_flush_pending_output
4910 md_flush_pending_output ();
4914 filename
= demand_copy_string (& len
);
4915 if (filename
== NULL
)
4920 /* Look for optional skip and count. */
4921 if (* input_line_pointer
== ',')
4923 ++ input_line_pointer
;
4924 skip
= get_absolute_expression ();
4928 if (* input_line_pointer
== ',')
4930 ++ input_line_pointer
;
4932 count
= get_absolute_expression ();
4934 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
4940 demand_empty_rest_of_line ();
4942 /* Try opening absolute path first, then try include dirs. */
4943 binfile
= fopen (filename
, FOPEN_RB
);
4944 if (binfile
== NULL
)
4948 path
= xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
4950 for (i
= 0; i
< include_dir_count
; i
++)
4952 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
4954 binfile
= fopen (path
, FOPEN_RB
);
4955 if (binfile
!= NULL
)
4959 if (binfile
== NULL
)
4960 as_bad (_("file not found: %s"), filename
);
4963 path
= xstrdup (filename
);
4969 register_dependency (path
);
4971 /* Compute the length of the file. */
4972 if (fseek (binfile
, 0, SEEK_END
) != 0)
4974 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
4977 file_len
= ftell (binfile
);
4979 /* If a count was not specified use the size of the file. */
4983 if (skip
+ count
> file_len
)
4985 as_bad (_("skip (%ld) + count (%ld) larger than file size (%ld)"),
4986 skip
, count
, file_len
);
4990 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
4992 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
4996 /* Allocate frag space and store file contents in it. */
4997 binfrag
= frag_more (count
);
4999 bytes
= fread (binfrag
, 1, count
, binfile
);
5001 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5002 path
, bytes
, count
);
5005 if (binfile
!= NULL
)
5011 /* .include -- include a file at this point. */
5014 s_include (int arg ATTRIBUTE_UNUSED
)
5023 filename
= demand_copy_string (&i
);
5024 if (filename
== NULL
)
5026 /* demand_copy_string has already printed an error and
5027 called ignore_rest_of_line. */
5035 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5036 && *input_line_pointer
!= ' '
5037 && *input_line_pointer
!= '\t')
5039 obstack_1grow (¬es
, *input_line_pointer
);
5040 ++input_line_pointer
;
5044 obstack_1grow (¬es
, '\0');
5045 filename
= obstack_finish (¬es
);
5046 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5047 ++input_line_pointer
;
5050 demand_empty_rest_of_line ();
5051 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
5053 for (i
= 0; i
< include_dir_count
; i
++)
5055 strcpy (path
, include_dirs
[i
]);
5057 strcat (path
, filename
);
5058 if (0 != (try = fopen (path
, FOPEN_RT
)))
5068 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5069 register_dependency (path
);
5070 input_scrub_insert_file (path
);
5074 add_include_dir (char *path
)
5078 if (include_dir_count
== 0)
5080 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5081 include_dirs
[0] = "."; /* Current dir. */
5082 include_dir_count
= 2;
5086 include_dir_count
++;
5088 (char **) realloc (include_dirs
,
5089 include_dir_count
* sizeof (*include_dirs
));
5092 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5095 if (i
> include_dir_maxlen
)
5096 include_dir_maxlen
= i
;
5099 /* Output debugging information to denote the source file. */
5102 generate_file_debug (void)
5104 if (debug_type
== DEBUG_STABS
)
5105 stabs_generate_asm_file ();
5108 /* Output line number debugging information for the current source line. */
5111 generate_lineno_debug (void)
5115 case DEBUG_UNSPECIFIED
:
5120 stabs_generate_asm_lineno ();
5123 ecoff_generate_asm_lineno ();
5126 /* ??? We could here indicate to dwarf2dbg.c that something
5127 has changed. However, since there is additional backend
5128 support that is required (calling dwarf2_emit_insn), we
5129 let dwarf2dbg.c call as_where on its own. */
5134 /* Output debugging information to mark a function entry point or end point.
5135 END_P is zero for .func, and non-zero for .endfunc. */
5140 do_s_func (end_p
, NULL
);
5143 /* Subroutine of s_func so targets can choose a different default prefix.
5144 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5147 do_s_func (int end_p
, const char *default_prefix
)
5149 /* Record the current function so that we can issue an error message for
5150 misplaced .func,.endfunc, and also so that .endfunc needs no
5152 static char *current_name
;
5153 static char *current_label
;
5157 if (current_name
== NULL
)
5159 as_bad (_("missing .func"));
5160 ignore_rest_of_line ();
5164 if (debug_type
== DEBUG_STABS
)
5165 stabs_generate_asm_endfunc (current_name
, current_label
);
5167 current_name
= current_label
= NULL
;
5172 char delim1
, delim2
;
5174 if (current_name
!= NULL
)
5176 as_bad (_(".endfunc missing for previous .func"));
5177 ignore_rest_of_line ();
5181 name
= input_line_pointer
;
5182 delim1
= get_symbol_end ();
5183 name
= xstrdup (name
);
5184 *input_line_pointer
= delim1
;
5186 if (*input_line_pointer
!= ',')
5189 asprintf (&label
, "%s%s", default_prefix
, name
);
5192 char leading_char
= 0;
5193 #ifdef BFD_ASSEMBLER
5194 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5196 /* Missing entry point, use function's name with the leading
5199 asprintf (&label
, "%c%s", leading_char
, name
);
5206 ++input_line_pointer
;
5208 label
= input_line_pointer
;
5209 delim2
= get_symbol_end ();
5210 label
= xstrdup (label
);
5211 *input_line_pointer
= delim2
;
5214 if (debug_type
== DEBUG_STABS
)
5215 stabs_generate_asm_func (name
, label
);
5217 current_name
= name
;
5218 current_label
= label
;
5221 demand_empty_rest_of_line ();
5225 s_ignore (int arg ATTRIBUTE_UNUSED
)
5227 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5229 ++input_line_pointer
;
5231 ++input_line_pointer
;
5235 read_print_statistics (FILE *file
)
5237 hash_print_statistics (file
, "pseudo-op table", po_hash
);
5240 /* Inserts the given line into the input stream.
5242 This call avoids macro/conditionals nesting checking, since the contents of
5243 the line are assumed to replace the contents of a line already scanned.
5245 An appropriate use of this function would be substitution of input lines when
5246 called by md_start_line_hook(). The given line is assumed to already be
5247 properly scrubbed. */
5250 input_scrub_insert_line (const char *line
)
5254 sb_add_string (&newline
, line
);
5255 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
5257 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
5260 /* Insert a file into the input stream; the path must resolve to an actual
5261 file; no include path searching or dependency registering is performed. */
5264 input_scrub_insert_file (char *path
)
5266 input_scrub_include_file (path
, input_line_pointer
);
5267 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);