1 /* read.c - read a source file -
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* If your chars aren't 8 bits, you will change this a bit.
24 But then, GNU isn't spozed to run on your machine anyway.
25 (RMS is so shortsighted sometimes.) */
26 #define MASK_CHAR (0xFF)
28 #define MASK_CHAR ((int)(unsigned char) -1)
31 /* This is the largest known floating point format (for now). It will
32 grow when we do 4361 style flonums. */
33 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
35 /* Routines that read assembler source text to build spagetti in memory.
36 Another group of these functions is in the expr.c module. */
39 #include "safe-ctype.h"
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
PARAMS ((int, int));
218 static int scrub_from_string
PARAMS ((char *, int));
219 static void do_align
PARAMS ((int, char *, int, int));
220 static void s_align
PARAMS ((int, int));
221 static void s_lcomm_internal
PARAMS ((int, int));
222 static int hex_float
PARAMS ((int, char *));
223 static inline int sizeof_sleb128
PARAMS ((offsetT
));
224 static inline int sizeof_uleb128
PARAMS ((valueT
));
225 static inline int output_sleb128
PARAMS ((char *, offsetT
));
226 static inline int output_uleb128
PARAMS ((char *, valueT
));
227 static inline int output_big_sleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
228 static inline int output_big_uleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
229 static int output_big_leb128
PARAMS ((char *, LITTLENUM_TYPE
*, int, int));
230 static void do_org
PARAMS ((segT
, expressionS
*, int));
231 char *demand_copy_string
PARAMS ((int *lenP
));
232 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
233 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
234 static void pobegin
PARAMS ((void));
235 static int get_line_sb
PARAMS ((sb
*));
236 static void generate_file_debug
PARAMS ((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
;
434 const pseudo_typeS
*table
;
437 const pseudo_typeS
*pop
;
438 for (pop
= table
; pop
->poc_name
; pop
++)
440 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
441 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
442 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
447 #ifndef md_pop_insert
448 #define md_pop_insert() pop_insert(md_pseudo_table)
451 #ifndef obj_pop_insert
452 #define obj_pop_insert() pop_insert(obj_pseudo_table)
455 #ifndef cfi_pop_insert
456 #define cfi_pop_insert() pop_insert(cfi_pseudo_table)
462 po_hash
= hash_new ();
464 /* Do the target-specific pseudo ops. */
465 pop_table_name
= "md";
468 /* Now object specific. Skip any that were in the target table. */
469 pop_table_name
= "obj";
473 /* Now portable ones. Skip any that we've seen already. */
474 pop_table_name
= "standard";
475 pop_insert (potable
);
477 #ifdef TARGET_USE_CFIPOP
478 pop_table_name
= "cfi";
484 #define HANDLE_CONDITIONAL_ASSEMBLY() \
485 if (ignore_input ()) \
487 while (!is_end_of_line[(unsigned char) *input_line_pointer++]) \
488 if (input_line_pointer == buffer_limit) \
493 /* This function is used when scrubbing the characters between #APP
496 static char *scrub_string
;
497 static char *scrub_string_end
;
500 scrub_from_string (buf
, buflen
)
506 copy
= scrub_string_end
- scrub_string
;
509 memcpy (buf
, scrub_string
, copy
);
510 scrub_string
+= copy
;
514 /* We read the file, putting things into a web that represents what we
515 have been reading. */
517 read_a_source_file (name
)
521 register char *s
; /* String of symbol, '\0' appended. */
529 buffer
= input_scrub_new_file (name
);
532 listing_newline (NULL
);
533 register_dependency (name
);
535 /* Generate debugging information before we've read anything in to denote
536 this file as the "main" source file and not a subordinate one
537 (e.g. N_SO vs N_SOL in stabs). */
538 generate_file_debug ();
540 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
541 { /* We have another line to parse. */
542 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
544 while (input_line_pointer
< buffer_limit
)
546 /* We have more of this buffer to parse. */
548 /* We now have input_line_pointer->1st char of next line.
549 If input_line_pointer [-1] == '\n' then we just
550 scanned another line: so bump line counters. */
551 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
553 #ifdef md_start_line_hook
554 md_start_line_hook ();
556 if (input_line_pointer
[-1] == '\n')
557 bump_line_counters ();
561 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
563 /* Text at the start of a line must be a label, we
564 run down and stick a colon in. */
565 if (is_name_beginner (*input_line_pointer
))
567 char *line_start
= input_line_pointer
;
572 HANDLE_CONDITIONAL_ASSEMBLY ();
574 c
= get_symbol_end ();
576 /* In MRI mode, the EQU and MACRO pseudoops must
577 be handled specially. */
581 char *rest
= input_line_pointer
+ 1;
585 if (*rest
== ' ' || *rest
== '\t')
587 if ((strncasecmp (rest
, "EQU", 3) == 0
588 || strncasecmp (rest
, "SET", 3) == 0)
589 && (rest
[3] == ' ' || rest
[3] == '\t'))
591 input_line_pointer
= rest
+ 3;
593 strncasecmp (rest
, "SET", 3) == 0);
596 if (strncasecmp (rest
, "MACRO", 5) == 0
599 || is_end_of_line
[(unsigned char) rest
[5]]))
603 /* In MRI mode, we need to handle the MACRO
604 pseudo-op specially: we don't want to put the
605 symbol in the symbol table. */
607 #ifdef TC_START_LABEL_WITHOUT_COLON
608 && TC_START_LABEL_WITHOUT_COLON(c
,
612 line_label
= colon (line_start
);
614 line_label
= symbol_create (line_start
,
619 *input_line_pointer
= c
;
621 input_line_pointer
++;
626 /* We are at the begining of a line, or similar place.
627 We expect a well-formed assembler statement.
628 A "symbol-name:" is a statement.
630 Depending on what compiler is used, the order of these tests
631 may vary to catch most common case 1st.
632 Each test is independent of all other tests at the (top) level.
633 PLEASE make a compiler that doesn't use this assembler.
634 It is crufty to waste a compiler's time encoding things for this
635 assembler, which then wastes more time decoding it.
636 (And communicating via (linear) files is silly!
637 If you must pass stuff, please pass a tree!) */
638 if ((c
= *input_line_pointer
++) == '\t'
642 c
= *input_line_pointer
++;
644 know (c
!= ' '); /* No further leading whitespace. */
647 /* If listing is on, and we are expanding a macro, then give
648 the listing code the contents of the expanded line. */
651 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
656 /* Find the end of the current expanded macro line. */
657 for (s
= input_line_pointer
- 1; *s
; ++s
)
658 if (is_end_of_line
[(unsigned char) *s
])
661 /* Copy it for safe keeping. Also give an indication of
662 how much macro nesting is involved at this point. */
663 len
= s
- (input_line_pointer
- 1);
664 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
665 memset (copy
, '>', macro_nest
);
666 copy
[macro_nest
] = ' ';
667 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
- 1, len
);
668 copy
[macro_nest
+ 1 + len
] = '\0';
670 /* Install the line with the listing facility. */
671 listing_newline (copy
);
674 listing_newline (NULL
);
677 /* C is the 1st significant character.
678 Input_line_pointer points after that character. */
679 if (is_name_beginner (c
))
681 /* Want user-defined label or pseudo/opcode. */
682 HANDLE_CONDITIONAL_ASSEMBLY ();
684 s
= --input_line_pointer
;
685 c
= get_symbol_end (); /* name's delimiter. */
687 /* C is character after symbol.
688 That character's place in the input line is now '\0'.
689 S points to the beginning of the symbol.
690 [In case of pseudo-op, s->'.'.]
691 Input_line_pointer->'\0' where c was. */
692 if (TC_START_LABEL (c
, input_line_pointer
))
696 char *rest
= input_line_pointer
+ 1;
698 /* In MRI mode, \tsym: set 0 is permitted. */
702 if (*rest
== ' ' || *rest
== '\t')
705 if ((strncasecmp (rest
, "EQU", 3) == 0
706 || strncasecmp (rest
, "SET", 3) == 0)
707 && (rest
[3] == ' ' || rest
[3] == '\t'))
709 input_line_pointer
= rest
+ 3;
715 line_label
= colon (s
); /* User-defined label. */
716 /* Put ':' back for error messages' sake. */
717 *input_line_pointer
++ = ':';
718 #ifdef tc_check_label
719 tc_check_label (line_label
);
721 /* Input_line_pointer->after ':'. */
725 || ((c
== ' ' || c
== '\t')
726 && input_line_pointer
[1] == '='
727 #ifdef TC_EQUAL_IN_INSN
728 && !TC_EQUAL_IN_INSN (c
, input_line_pointer
)
733 demand_empty_rest_of_line ();
737 /* Expect pseudo-op or machine instruction. */
740 #ifdef IGNORE_OPCODE_CASE
744 strncpy (original_case_string
, s2
, sizeof (original_case_string
));
745 original_case_string
[sizeof (original_case_string
) - 1] = 0;
754 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
756 /* The MRI assembler and the m88k use pseudo-ops
758 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
759 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
764 || (!flag_m68k_mri
&& *s
== '.'))
768 WARNING: c has next char, which may be end-of-line.
769 We lookup the pseudo-op table with s+1 because we
770 already know that the pseudo-op begins with a '.'. */
773 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
775 /* In MRI mode, we may need to insert an
776 automatic alignment directive. What a hack
778 if (mri_pending_align
780 || !((pop
->poc_handler
== cons
781 && pop
->poc_val
== 1)
782 || (pop
->poc_handler
== s_space
783 && pop
->poc_val
== 1)
784 #ifdef tc_conditional_pseudoop
785 || tc_conditional_pseudoop (pop
)
787 || pop
->poc_handler
== s_if
788 || pop
->poc_handler
== s_ifdef
789 || pop
->poc_handler
== s_ifc
790 || pop
->poc_handler
== s_ifeqs
791 || pop
->poc_handler
== s_else
792 || pop
->poc_handler
== s_endif
793 || pop
->poc_handler
== s_globl
794 || pop
->poc_handler
== s_ignore
)))
796 do_align (1, (char *) NULL
, 0, 0);
797 mri_pending_align
= 0;
799 if (line_label
!= NULL
)
801 symbol_set_frag (line_label
, frag_now
);
802 S_SET_VALUE (line_label
, frag_now_fix ());
806 /* Print the error msg now, while we still can. */
809 as_bad (_("unknown pseudo-op: `%s'"), s
);
810 *input_line_pointer
= c
;
815 /* Put it back for error messages etc. */
816 *input_line_pointer
= c
;
817 /* The following skip of whitespace is compulsory.
818 A well shaped space is sometimes all that separates
819 keyword from operands. */
820 if (c
== ' ' || c
== '\t')
821 input_line_pointer
++;
823 /* Input_line is restored.
824 Input_line_pointer->1st non-blank char
825 after pseudo-operation. */
826 (*pop
->poc_handler
) (pop
->poc_val
);
828 /* If that was .end, just get out now. */
829 if (pop
->poc_handler
== s_end
)
835 #ifdef QUOTES_IN_INSN
839 /* WARNING: c has char, which may be end-of-line. */
840 /* Also: input_line_pointer->`\0` where c was. */
841 *input_line_pointer
= c
;
842 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
844 #ifdef TC_EOL_IN_INSN
845 || TC_EOL_IN_INSN (input_line_pointer
)
849 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
851 #ifdef QUOTES_IN_INSN
854 else if (*input_line_pointer
== '"')
856 else if (*input_line_pointer
== '\\')
859 input_line_pointer
++;
862 c
= *input_line_pointer
;
863 *input_line_pointer
= '\0';
865 generate_lineno_debug ();
873 if (check_macro (s
, &out
, &err
, ¯o
))
877 *input_line_pointer
++ = c
;
878 input_scrub_include_sb (&out
,
879 input_line_pointer
, 1);
882 input_scrub_next_buffer (&input_line_pointer
);
884 md_macro_info (macro
);
890 if (mri_pending_align
)
892 do_align (1, (char *) NULL
, 0, 0);
893 mri_pending_align
= 0;
894 if (line_label
!= NULL
)
896 symbol_set_frag (line_label
, frag_now
);
897 S_SET_VALUE (line_label
, frag_now_fix ());
901 md_assemble (s
); /* Assemble 1 instruction. */
903 *input_line_pointer
++ = c
;
905 /* We resume loop AFTER the end-of-line from
912 /* Empty statement? */
913 if (is_end_of_line
[(unsigned char) c
])
916 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
) && ISDIGIT (c
))
918 /* local label ("4:") */
919 char *backup
= input_line_pointer
;
921 HANDLE_CONDITIONAL_ASSEMBLY ();
925 /* Read the whole number. */
926 while (ISDIGIT (*input_line_pointer
))
928 temp
= (temp
* 10) + *input_line_pointer
- '0';
929 ++input_line_pointer
;
932 if (LOCAL_LABELS_DOLLAR
933 && *input_line_pointer
== '$'
934 && *(input_line_pointer
+ 1) == ':')
936 input_line_pointer
+= 2;
938 if (dollar_label_defined (temp
))
940 as_fatal (_("label \"%d$\" redefined"), temp
);
943 define_dollar_label (temp
);
944 colon (dollar_label_name (temp
, 0));
949 && *input_line_pointer
++ == ':')
951 fb_label_instance_inc (temp
);
952 colon (fb_label_name (temp
, 0));
956 input_line_pointer
= backup
;
957 } /* local label ("4:") */
959 if (c
&& strchr (line_comment_chars
, c
))
960 { /* Its a comment. Better say APP or NO_APP. */
965 unsigned int new_length
;
968 bump_line_counters ();
969 s
= input_line_pointer
;
970 if (strncmp (s
, "APP\n", 4))
971 continue; /* We ignore it */
975 ends
= strstr (s
, "#NO_APP\n");
979 unsigned int tmp_len
;
982 /* The end of the #APP wasn't in this buffer. We
983 keep reading in buffers until we find the #NO_APP
984 that goes with this #APP There is one. The specs
986 tmp_len
= buffer_limit
- s
;
987 tmp_buf
= xmalloc (tmp_len
+ 1);
988 memcpy (tmp_buf
, s
, tmp_len
);
991 new_tmp
= input_scrub_next_buffer (&buffer
);
995 buffer_limit
= new_tmp
;
996 input_line_pointer
= buffer
;
997 ends
= strstr (buffer
, "#NO_APP\n");
1001 num
= buffer_limit
- buffer
;
1003 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
1004 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
1009 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1017 input_line_pointer
= ends
+ 8;
1021 scrub_string_end
= ends
;
1023 new_length
= ends
- s
;
1024 new_buf
= (char *) xmalloc (new_length
);
1031 space
= (new_buf
+ new_length
) - new_tmp
;
1032 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1040 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1041 new_tmp
= new_buf
+ new_length
;
1048 /* We've "scrubbed" input to the preferred format. In the
1049 process we may have consumed the whole of the remaining
1050 file (and included files). We handle this formatted
1051 input similar to that of macro expansion, letting
1052 actual macro expansion (possibly nested) and other
1053 input expansion work. Beware that in messages, line
1054 numbers and possibly file names will be incorrect. */
1055 sb_add_string (&sbuf
, new_buf
);
1056 input_scrub_include_sb (&sbuf
, input_line_pointer
, 0);
1058 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1063 HANDLE_CONDITIONAL_ASSEMBLY ();
1065 #ifdef tc_unrecognized_line
1066 if (tc_unrecognized_line (c
))
1069 input_line_pointer
--;
1070 /* Report unknown char as ignored. */
1071 ignore_rest_of_line ();
1074 #ifdef md_after_pass_hook
1075 md_after_pass_hook ();
1084 /* Close the input file. */
1085 input_scrub_close ();
1086 #ifdef WARN_COMMENTS
1088 if (warn_comment
&& found_comment
)
1089 as_warn_where (found_comment_file
, found_comment
,
1090 "first comment found here");
1095 /* For most MRI pseudo-ops, the line actually ends at the first
1096 nonquoted space. This function looks for that point, stuffs a null
1097 in, and sets *STOPCP to the character that used to be there, and
1098 returns the location.
1100 Until I hear otherwise, I am going to assume that this is only true
1101 for the m68k MRI assembler. */
1104 mri_comment_field (stopcp
)
1111 know (flag_m68k_mri
);
1113 for (s
= input_line_pointer
;
1114 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1122 for (s
= input_line_pointer
;
1123 !is_end_of_line
[(unsigned char) *s
];
1133 /* Skip to the end of an MRI comment field. */
1136 mri_comment_end (stop
, stopc
)
1142 input_line_pointer
= stop
;
1144 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1145 ++input_line_pointer
;
1150 int ignore ATTRIBUTE_UNUSED
;
1152 as_fatal (_(".abort detected. Abandoning ship."));
1155 /* Guts of .align directive. N is the power of two to which to align.
1156 FILL may be NULL, or it may point to the bytes of the fill pattern.
1157 LEN is the length of whatever FILL points to, if anything. MAX is
1158 the maximum number of characters to skip when doing the alignment,
1159 or 0 if there is no maximum. */
1162 do_align (n
, fill
, len
, max
)
1168 if (now_seg
== absolute_section
)
1172 if (*fill
++ != '\0')
1174 as_warn (_("ignoring fill value in absolute section"));
1182 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1185 /* Only make a frag if we HAVE to... */
1186 if (n
!= 0 && !need_pass_2
)
1190 if (subseg_text_p (now_seg
))
1191 frag_align_code (n
, max
);
1193 frag_align (n
, 0, max
);
1196 frag_align (n
, *fill
, max
);
1198 frag_align_pattern (n
, fill
, len
, max
);
1202 just_record_alignment
: ATTRIBUTE_UNUSED_LABEL
1205 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1208 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1209 (in bytes). A negative ARG is the negative of the length of the
1210 fill pattern. BYTES_P is non-zero if the alignment value should be
1211 interpreted as the byte boundary, rather than the power of 2. */
1214 s_align (arg
, bytes_p
)
1218 register unsigned int align
;
1226 stop
= mri_comment_field (&stopc
);
1228 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1233 align
= arg
; /* Default value from pseudo-op table. */
1237 align
= get_absolute_expression ();
1243 /* Convert to a power of 2. */
1248 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1251 as_bad (_("alignment not a power of 2"));
1260 as_warn (_("alignment too large: %u assumed"), align
);
1263 if (*input_line_pointer
!= ',')
1270 ++input_line_pointer
;
1271 if (*input_line_pointer
== ',')
1275 fill
= get_absolute_expression ();
1280 if (*input_line_pointer
!= ',')
1284 ++input_line_pointer
;
1285 max
= get_absolute_expression ();
1292 as_warn (_("expected fill pattern missing"));
1293 do_align (align
, (char *) NULL
, 0, max
);
1308 do_align (align
, &fill_char
, fill_len
, max
);
1314 if ((size_t) fill_len
> sizeof ab
)
1316 md_number_to_chars (ab
, fill
, fill_len
);
1317 do_align (align
, ab
, fill_len
, max
);
1321 demand_empty_rest_of_line ();
1324 mri_comment_end (stop
, stopc
);
1327 /* Handle the .align pseudo-op on machines where ".align 4" means
1328 align to a 4 byte boundary. */
1337 /* Handle the .align pseudo-op on machines where ".align 4" means align
1338 to a 2**4 boundary. */
1349 int ignore ATTRIBUTE_UNUSED
;
1351 register char *name
;
1355 register symbolS
*symbolP
;
1360 stop
= mri_comment_field (&stopc
);
1362 name
= input_line_pointer
;
1363 c
= get_symbol_end ();
1364 /* Just after name is now '\0'. */
1365 p
= input_line_pointer
;
1370 as_bad (_("expected symbol name"));
1371 discard_rest_of_line ();
1377 if (*input_line_pointer
!= ',')
1380 as_bad (_("expected comma after \"%s\""), name
);
1382 ignore_rest_of_line ();
1384 mri_comment_end (stop
, stopc
);
1388 input_line_pointer
++; /* skip ',' */
1390 if ((temp
= get_absolute_expression ()) < 0)
1392 as_warn (_(".COMMon length (%ld) < 0 ignored"), (long) temp
);
1393 ignore_rest_of_line ();
1395 mri_comment_end (stop
, stopc
);
1400 symbolP
= symbol_find_or_make (name
);
1403 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1405 as_bad (_("symbol `%s' is already defined"),
1406 S_GET_NAME (symbolP
));
1407 ignore_rest_of_line ();
1409 mri_comment_end (stop
, stopc
);
1413 if (S_GET_VALUE (symbolP
))
1415 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1416 as_bad (_("length of .comm \"%s\" is already %ld; not changing to %ld"),
1417 S_GET_NAME (symbolP
),
1418 (long) S_GET_VALUE (symbolP
),
1423 S_SET_VALUE (symbolP
, (valueT
) temp
);
1424 S_SET_EXTERNAL (symbolP
);
1428 extern int flag_one
;
1429 if (!temp
|| !flag_one
)
1430 S_GET_OTHER(symbolP
) = const_flag
;
1432 #endif /* not OBJ_VMS */
1433 know (symbolP
->sy_frag
== &zero_address_frag
);
1435 demand_empty_rest_of_line ();
1438 mri_comment_end (stop
, stopc
);
1441 /* The MRI COMMON pseudo-op. We handle this by creating a common
1442 symbol with the appropriate name. We make s_space do the right
1443 thing by increasing the size. */
1446 s_mri_common (small
)
1447 int small ATTRIBUTE_UNUSED
;
1463 stop
= mri_comment_field (&stopc
);
1467 name
= input_line_pointer
;
1468 if (!ISDIGIT (*name
))
1469 c
= get_symbol_end ();
1474 ++input_line_pointer
;
1476 while (ISDIGIT (*input_line_pointer
));
1478 c
= *input_line_pointer
;
1479 *input_line_pointer
= '\0';
1481 if (line_label
!= NULL
)
1483 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1484 + (input_line_pointer
- name
)
1486 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1491 sym
= symbol_find_or_make (name
);
1492 *input_line_pointer
= c
;
1496 if (*input_line_pointer
!= ',')
1500 ++input_line_pointer
;
1501 align
= get_absolute_expression ();
1504 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1506 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1507 ignore_rest_of_line ();
1508 mri_comment_end (stop
, stopc
);
1512 S_SET_EXTERNAL (sym
);
1513 mri_common_symbol
= sym
;
1517 S_SET_ALIGN (sym
, align
);
1520 if (line_label
!= NULL
)
1523 exp
.X_op
= O_symbol
;
1524 exp
.X_add_symbol
= sym
;
1525 exp
.X_add_number
= 0;
1526 symbol_set_value_expression (line_label
, &exp
);
1527 symbol_set_frag (line_label
, &zero_address_frag
);
1528 S_SET_SEGMENT (line_label
, expr_section
);
1531 /* FIXME: We just ignore the small argument, which distinguishes
1532 COMMON and COMMON.S. I don't know what we can do about it. */
1534 /* Ignore the type and hptype. */
1535 if (*input_line_pointer
== ',')
1536 input_line_pointer
+= 2;
1537 if (*input_line_pointer
== ',')
1538 input_line_pointer
+= 2;
1540 demand_empty_rest_of_line ();
1542 mri_comment_end (stop
, stopc
);
1547 int ignore ATTRIBUTE_UNUSED
;
1552 temp
= get_absolute_expression ();
1553 if (flag_readonly_data_in_text
)
1555 section
= text_section
;
1559 section
= data_section
;
1561 subseg_set (section
, (subsegT
) temp
);
1566 demand_empty_rest_of_line ();
1569 /* Handle the .appfile pseudo-op. This is automatically generated by
1570 do_scrub_chars when a preprocessor # line comment is seen with a
1571 file name. This default definition may be overridden by the object
1572 or CPU specific pseudo-ops. This function is also the default
1573 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1577 s_app_file_string (file
)
1582 listing_source_file (file
);
1584 register_dependency (file
);
1586 obj_app_file (file
);
1591 s_app_file (appfile
)
1597 /* Some assemblers tolerate immediately following '"'. */
1598 if ((s
= demand_copy_string (&length
)) != 0)
1600 /* If this is a fake .appfile, a fake newline was inserted into
1601 the buffer. Passing -2 to new_logical_line tells it to
1604 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1606 /* In MRI mode, the preprocessor may have inserted an extraneous
1609 && *input_line_pointer
== '\''
1610 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1611 ++input_line_pointer
;
1613 demand_empty_rest_of_line ();
1615 s_app_file_string (s
);
1619 /* Handle the .appline pseudo-op. This is automatically generated by
1620 do_scrub_chars when a preprocessor # line comment is seen. This
1621 default definition may be overridden by the object or CPU specific
1626 int ignore ATTRIBUTE_UNUSED
;
1630 /* The given number is that of the next line. */
1631 l
= get_absolute_expression () - 1;
1633 /* Some of the back ends can't deal with non-positive line numbers.
1634 Besides, it's silly. */
1635 as_warn (_("line numbers must be positive; line number %d rejected"),
1639 new_logical_line ((char *) NULL
, l
);
1642 listing_source_line (l
);
1645 demand_empty_rest_of_line ();
1648 /* Handle the .end pseudo-op. Actually, the real work is done in
1649 read_a_source_file. */
1653 int ignore ATTRIBUTE_UNUSED
;
1657 /* The MRI assembler permits the start symbol to follow .end,
1658 but we don't support that. */
1660 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1661 && *input_line_pointer
!= '*'
1662 && *input_line_pointer
!= '!')
1663 as_warn (_("start address not supported"));
1667 /* Handle the .err pseudo-op. */
1671 int ignore ATTRIBUTE_UNUSED
;
1673 as_bad (_(".err encountered"));
1674 demand_empty_rest_of_line ();
1677 /* Handle the MRI fail pseudo-op. */
1681 int ignore ATTRIBUTE_UNUSED
;
1688 stop
= mri_comment_field (&stopc
);
1690 temp
= get_absolute_expression ();
1692 as_warn (_(".fail %ld encountered"), (long) temp
);
1694 as_bad (_(".fail %ld encountered"), (long) temp
);
1696 demand_empty_rest_of_line ();
1699 mri_comment_end (stop
, stopc
);
1704 int ignore ATTRIBUTE_UNUSED
;
1706 expressionS rep_exp
;
1708 register long fill
= 0;
1711 #ifdef md_flush_pending_output
1712 md_flush_pending_output ();
1715 get_known_segmented_expression (&rep_exp
);
1716 if (*input_line_pointer
== ',')
1718 input_line_pointer
++;
1719 size
= get_absolute_expression ();
1720 if (*input_line_pointer
== ',')
1722 input_line_pointer
++;
1723 fill
= get_absolute_expression ();
1727 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1728 #define BSD_FILL_SIZE_CROCK_8 (8)
1729 if (size
> BSD_FILL_SIZE_CROCK_8
)
1731 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
1732 size
= BSD_FILL_SIZE_CROCK_8
;
1736 as_warn (_("size negative; .fill ignored"));
1739 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1741 if (rep_exp
.X_add_number
< 0)
1742 as_warn (_("repeat < 0; .fill ignored"));
1746 if (size
&& !need_pass_2
)
1748 if (rep_exp
.X_op
== O_constant
)
1750 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1751 (relax_substateT
) 0, (symbolS
*) 0,
1752 (offsetT
) rep_exp
.X_add_number
,
1757 /* We don't have a constant repeat count, so we can't use
1758 rs_fill. We can get the same results out of rs_space,
1759 but its argument is in bytes, so we must multiply the
1760 repeat count by size. */
1763 rep_sym
= make_expr_symbol (&rep_exp
);
1766 expressionS size_exp
;
1767 size_exp
.X_op
= O_constant
;
1768 size_exp
.X_add_number
= size
;
1770 rep_exp
.X_op
= O_multiply
;
1771 rep_exp
.X_add_symbol
= rep_sym
;
1772 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1773 rep_exp
.X_add_number
= 0;
1774 rep_sym
= make_expr_symbol (&rep_exp
);
1777 p
= frag_var (rs_space
, (int) size
, (int) size
,
1778 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1781 memset (p
, 0, (unsigned int) size
);
1783 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1784 flavoured AS. The following bizarre behaviour is to be
1785 compatible with above. I guess they tried to take up to 8
1786 bytes from a 4-byte expression and they forgot to sign
1788 #define BSD_FILL_SIZE_CROCK_4 (4)
1789 md_number_to_chars (p
, (valueT
) fill
,
1790 (size
> BSD_FILL_SIZE_CROCK_4
1791 ? BSD_FILL_SIZE_CROCK_4
1793 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1794 but emits no error message because it seems a legal thing to do.
1795 It is a degenerate case of .fill but could be emitted by a
1798 demand_empty_rest_of_line ();
1803 int ignore ATTRIBUTE_UNUSED
;
1812 stop
= mri_comment_field (&stopc
);
1816 name
= input_line_pointer
;
1817 c
= get_symbol_end ();
1818 symbolP
= symbol_find_or_make (name
);
1819 S_SET_EXTERNAL (symbolP
);
1821 *input_line_pointer
= c
;
1823 c
= *input_line_pointer
;
1826 input_line_pointer
++;
1828 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1834 demand_empty_rest_of_line ();
1837 mri_comment_end (stop
, stopc
);
1840 /* Handle the MRI IRP and IRPC pseudo-ops. */
1852 as_where (&file
, &line
);
1855 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1856 sb_add_char (&s
, *input_line_pointer
++);
1860 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
);
1862 as_bad_where (file
, line
, "%s", err
);
1866 input_scrub_include_sb (&out
, input_line_pointer
, 1);
1868 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1871 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1872 the section to only be linked once. However, this is not supported
1873 by most object file formats. This takes an optional argument,
1874 which is what to do about duplicates. */
1878 int ignore ATTRIBUTE_UNUSED
;
1880 enum linkonce_type type
;
1884 type
= LINKONCE_DISCARD
;
1886 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1891 s
= input_line_pointer
;
1892 c
= get_symbol_end ();
1893 if (strcasecmp (s
, "discard") == 0)
1894 type
= LINKONCE_DISCARD
;
1895 else if (strcasecmp (s
, "one_only") == 0)
1896 type
= LINKONCE_ONE_ONLY
;
1897 else if (strcasecmp (s
, "same_size") == 0)
1898 type
= LINKONCE_SAME_SIZE
;
1899 else if (strcasecmp (s
, "same_contents") == 0)
1900 type
= LINKONCE_SAME_CONTENTS
;
1902 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1904 *input_line_pointer
= c
;
1907 #ifdef obj_handle_link_once
1908 obj_handle_link_once (type
);
1909 #else /* ! defined (obj_handle_link_once) */
1910 #ifdef BFD_ASSEMBLER
1914 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1915 as_warn (_(".linkonce is not supported for this object file format"));
1917 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1918 flags
|= SEC_LINK_ONCE
;
1923 case LINKONCE_DISCARD
:
1924 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1926 case LINKONCE_ONE_ONLY
:
1927 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1929 case LINKONCE_SAME_SIZE
:
1930 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1932 case LINKONCE_SAME_CONTENTS
:
1933 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1936 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1937 as_bad (_("bfd_set_section_flags: %s"),
1938 bfd_errmsg (bfd_get_error ()));
1940 #else /* ! defined (BFD_ASSEMBLER) */
1941 as_warn (_(".linkonce is not supported for this object file format"));
1942 #endif /* ! defined (BFD_ASSEMBLER) */
1943 #endif /* ! defined (obj_handle_link_once) */
1945 demand_empty_rest_of_line ();
1949 s_lcomm_internal (needs_align
, bytes_p
)
1950 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1951 (alignment); 0 if it was an ".lcomm" (2 args only). */
1953 /* 1 if the alignment value should be interpreted as the byte boundary,
1954 rather than the power of 2. */
1957 register char *name
;
1961 register symbolS
*symbolP
;
1962 segT current_seg
= now_seg
;
1963 subsegT current_subseg
= now_subseg
;
1964 const int max_alignment
= 15;
1966 segT bss_seg
= bss_section
;
1968 name
= input_line_pointer
;
1969 c
= get_symbol_end ();
1970 p
= input_line_pointer
;
1975 as_bad (_("expected symbol name"));
1976 discard_rest_of_line ();
1982 /* Accept an optional comma after the name. The comma used to be
1983 required, but Irix 5 cc does not generate it. */
1984 if (*input_line_pointer
== ',')
1986 ++input_line_pointer
;
1990 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1992 as_bad (_("missing size expression"));
1996 if ((temp
= get_absolute_expression ()) < 0)
1998 as_warn (_("BSS length (%d) < 0 ignored"), temp
);
1999 ignore_rest_of_line ();
2003 #if defined (TC_MIPS) || defined (TC_ALPHA)
2004 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
2005 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
2007 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
2008 if ((unsigned) temp
<= bfd_get_gp_size (stdoutput
))
2010 bss_seg
= subseg_new (".sbss", 1);
2011 seg_info (bss_seg
)->bss
= 1;
2012 #ifdef BFD_ASSEMBLER
2013 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
2014 as_warn (_("error setting flags for \".sbss\": %s"),
2015 bfd_errmsg (bfd_get_error ()));
2023 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
2025 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
2027 record_alignment (bss_seg
, align
);
2035 if (*input_line_pointer
!= ',')
2037 as_bad (_("expected comma after size"));
2038 ignore_rest_of_line ();
2042 input_line_pointer
++;
2045 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2047 as_bad (_("missing alignment"));
2051 align
= get_absolute_expression ();
2055 /* Convert to a power of 2. */
2060 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2063 as_bad (_("alignment not a power of 2"));
2068 if (align
> max_alignment
)
2070 align
= max_alignment
;
2071 as_warn (_("alignment too large; %d assumed"), align
);
2076 as_warn (_("alignment negative; 0 assumed"));
2079 record_alignment (bss_seg
, align
);
2083 /* Assume some objects may require alignment on some systems. */
2084 #if defined (TC_ALPHA) && ! defined (VMS)
2087 align
= ffs (temp
) - 1;
2088 if (temp
% (1 << align
))
2095 symbolP
= symbol_find_or_make (name
);
2099 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2100 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2101 #ifdef BFD_ASSEMBLER
2102 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2103 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2105 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2108 (S_GET_SEGMENT (symbolP
) == bss_seg
2109 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2113 subseg_set (bss_seg
, 1);
2116 frag_align (align
, 0, 0);
2118 /* Detach from old frag. */
2119 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2120 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2122 symbol_set_frag (symbolP
, frag_now
);
2123 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2124 (offsetT
) temp
, (char *) 0);
2127 S_SET_SEGMENT (symbolP
, bss_seg
);
2130 /* The symbol may already have been created with a preceding
2131 ".globl" directive -- be careful not to step on storage class
2132 in that case. Otherwise, set it to static. */
2133 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2135 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2137 #endif /* OBJ_COFF */
2140 S_SET_SIZE (symbolP
, temp
);
2144 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2146 subseg_set (current_seg
, current_subseg
);
2148 demand_empty_rest_of_line ();
2152 s_lcomm (needs_align
)
2155 s_lcomm_internal (needs_align
, 0);
2159 s_lcomm_bytes (needs_align
)
2162 s_lcomm_internal (needs_align
, 1);
2167 int ignore ATTRIBUTE_UNUSED
;
2169 register char *name
;
2173 register symbolS
*symbolP
;
2175 /* We permit ANY defined expression: BSD4.2 demands constants. */
2176 name
= input_line_pointer
;
2177 c
= get_symbol_end ();
2178 p
= input_line_pointer
;
2183 as_bad (_("expected symbol name"));
2184 discard_rest_of_line ();
2190 if (*input_line_pointer
!= ',')
2193 as_bad (_("expected comma after \"%s\""), name
);
2195 ignore_rest_of_line ();
2199 input_line_pointer
++;
2202 if (exp
.X_op
!= O_constant
2203 && exp
.X_op
!= O_register
)
2205 as_bad (_("bad expression"));
2206 ignore_rest_of_line ();
2211 symbolP
= symbol_find_or_make (name
);
2213 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2214 symbolP->sy_desc == 0) out of this test because coff doesn't have
2215 those fields, and I can't see when they'd ever be tripped. I
2216 don't think I understand why they were here so I may have
2217 introduced a bug. As recently as 1.37 didn't have this test
2218 anyway. xoxorich. */
2220 if (S_GET_SEGMENT (symbolP
) == undefined_section
2221 && S_GET_VALUE (symbolP
) == 0)
2223 /* The name might be an undefined .global symbol; be sure to
2224 keep the "external" bit. */
2225 S_SET_SEGMENT (symbolP
,
2226 (exp
.X_op
== O_constant
2229 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2233 as_bad (_("symbol `%s' is already defined"), name
);
2237 demand_empty_rest_of_line ();
2240 /* Read a line into an sb. Returns the character that ended the line
2241 or zero if there are no more lines. */
2247 char quote1
, quote2
, inquote
;
2250 if (input_line_pointer
[-1] == '\n')
2251 bump_line_counters ();
2253 if (input_line_pointer
>= buffer_limit
)
2255 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2256 if (buffer_limit
== 0)
2260 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2261 code needs to be changed. */
2270 #ifdef LEX_IS_STRINGQUOTE
2276 while ((c
= * input_line_pointer
++) != 0
2277 && (!is_end_of_line
[c
]
2278 || (inquote
!= '\0' && c
!= '\n')))
2282 else if (inquote
== '\0')
2286 else if (c
== quote2
)
2290 sb_add_char (line
, c
);
2293 /* Don't skip multiple end-of-line characters, because that breaks support
2294 for the IA-64 stop bit (;;) which looks like two consecutive end-of-line
2295 characters but isn't. Instead just skip one end of line character and
2296 return the character skipped so that the caller can re-insert it if
2301 /* Define a macro. This is an interface to macro.c. */
2305 int ignore ATTRIBUTE_UNUSED
;
2314 as_where (&file
, &line
);
2317 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2318 sb_add_char (&s
, *input_line_pointer
++);
2321 if (line_label
!= NULL
)
2322 sb_add_string (&label
, S_GET_NAME (line_label
));
2324 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2326 as_bad_where (file
, line
, "%s", err
);
2329 if (line_label
!= NULL
)
2331 S_SET_SEGMENT (line_label
, undefined_section
);
2332 S_SET_VALUE (line_label
, 0);
2333 symbol_set_frag (line_label
, &zero_address_frag
);
2336 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2337 && hash_find (po_hash
, name
) != NULL
)
2340 && hash_find (po_hash
, name
+ 1) != NULL
))
2341 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2348 /* Handle the .mexit pseudo-op, which immediately exits a macro
2353 int ignore ATTRIBUTE_UNUSED
;
2355 cond_exit_macro (macro_nest
);
2356 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2359 /* Switch in and out of MRI mode. */
2363 int ignore ATTRIBUTE_UNUSED
;
2367 on
= get_absolute_expression ();
2368 old_flag
= flag_mri
;
2386 /* Operator precedence changes in m68k MRI mode, so we need to
2387 update the operator rankings. */
2388 expr_set_precedence ();
2390 #ifdef MRI_MODE_CHANGE
2392 MRI_MODE_CHANGE (on
);
2395 demand_empty_rest_of_line ();
2398 /* Handle changing the location counter. */
2401 do_org (segment
, exp
, fill
)
2406 if (segment
!= now_seg
&& segment
!= absolute_section
)
2407 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2409 if (now_seg
== absolute_section
)
2412 as_warn (_("ignoring fill value in absolute section"));
2413 if (exp
->X_op
!= O_constant
)
2415 as_bad (_("only constant offsets supported in absolute section"));
2416 exp
->X_add_number
= 0;
2418 abs_section_offset
= exp
->X_add_number
;
2423 symbolS
*sym
= exp
->X_add_symbol
;
2424 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2426 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2428 /* Handle complex expressions. */
2429 sym
= make_expr_symbol (exp
);
2433 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2440 int ignore ATTRIBUTE_UNUSED
;
2442 register segT segment
;
2444 register long temp_fill
;
2446 #ifdef md_flush_pending_output
2447 md_flush_pending_output ();
2450 /* The m68k MRI assembler has a different meaning for .org. It
2451 means to create an absolute section at a given address. We can't
2452 support that--use a linker script instead. */
2455 as_bad (_("MRI style ORG pseudo-op not supported"));
2456 ignore_rest_of_line ();
2460 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2461 thing as a sub-segment-relative origin. Any absolute origin is
2462 given a warning, then assumed to be segment-relative. Any
2463 segmented origin expression ("foo+42") had better be in the right
2464 segment or the .org is ignored.
2466 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2467 we never know sub-segment sizes when we are reading code. BSD
2468 will crash trying to emit negative numbers of filler bytes in
2469 certain .orgs. We don't crash, but see as-write for that code.
2471 Don't make frag if need_pass_2==1. */
2472 segment
= get_known_segmented_expression (&exp
);
2473 if (*input_line_pointer
== ',')
2475 input_line_pointer
++;
2476 temp_fill
= get_absolute_expression ();
2482 do_org (segment
, &exp
, temp_fill
);
2484 demand_empty_rest_of_line ();
2487 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2488 called by the obj-format routine which handles section changing
2489 when in MRI mode. It will create a new section, and return it. It
2490 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2491 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2492 flags will be set in the section. */
2496 char *type ATTRIBUTE_UNUSED
;
2506 name
= input_line_pointer
;
2507 if (!ISDIGIT (*name
))
2508 c
= get_symbol_end ();
2513 ++input_line_pointer
;
2515 while (ISDIGIT (*input_line_pointer
));
2517 c
= *input_line_pointer
;
2518 *input_line_pointer
= '\0';
2521 name
= xstrdup (name
);
2523 *input_line_pointer
= c
;
2525 seg
= subseg_new (name
, 0);
2527 if (*input_line_pointer
== ',')
2531 ++input_line_pointer
;
2532 align
= get_absolute_expression ();
2533 record_alignment (seg
, align
);
2537 if (*input_line_pointer
== ',')
2539 c
= *++input_line_pointer
;
2541 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2544 as_bad (_("unrecognized section type"));
2545 ++input_line_pointer
;
2547 #ifdef BFD_ASSEMBLER
2551 flags
= SEC_NO_FLAGS
;
2553 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2554 else if (*type
== 'D' || *type
== 'M')
2555 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2556 else if (*type
== 'R')
2557 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2558 if (flags
!= SEC_NO_FLAGS
)
2560 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2561 as_warn (_("error setting flags for \"%s\": %s"),
2562 bfd_section_name (stdoutput
, seg
),
2563 bfd_errmsg (bfd_get_error ()));
2569 /* Ignore the HP type. */
2570 if (*input_line_pointer
== ',')
2571 input_line_pointer
+= 2;
2573 demand_empty_rest_of_line ();
2575 #else /* ! TC_M68K */
2584 name
= input_line_pointer
;
2585 c
= get_symbol_end ();
2587 name
= xstrdup (name
);
2589 *input_line_pointer
= c
;
2591 seg
= subseg_new (name
, 0);
2593 if (*input_line_pointer
!= ',')
2599 ++input_line_pointer
;
2601 sectype
= input_line_pointer
;
2602 c
= get_symbol_end ();
2603 if (*sectype
== '\0')
2605 else if (strcasecmp (sectype
, "text") == 0)
2607 else if (strcasecmp (sectype
, "data") == 0)
2609 else if (strcasecmp (sectype
, "romdata") == 0)
2612 as_warn (_("unrecognized section type `%s'"), sectype
);
2613 *input_line_pointer
= c
;
2616 if (*input_line_pointer
== ',')
2620 ++input_line_pointer
;
2622 seccmd
= input_line_pointer
;
2623 c
= get_symbol_end ();
2624 if (strcasecmp (seccmd
, "absolute") == 0)
2626 as_bad (_("absolute sections are not supported"));
2627 *input_line_pointer
= c
;
2628 ignore_rest_of_line ();
2631 else if (strcasecmp (seccmd
, "align") == 0)
2635 *input_line_pointer
= c
;
2636 align
= get_absolute_expression ();
2637 record_alignment (seg
, align
);
2641 as_warn (_("unrecognized section command `%s'"), seccmd
);
2642 *input_line_pointer
= c
;
2646 demand_empty_rest_of_line ();
2648 #else /* ! TC_I960 */
2649 /* The MRI assembler seems to use different forms of .sect for
2650 different targets. */
2651 as_bad ("MRI mode not supported for this target");
2652 ignore_rest_of_line ();
2653 #endif /* ! TC_I960 */
2654 #endif /* ! TC_M68K */
2657 /* Handle the .print pseudo-op. */
2661 int ignore ATTRIBUTE_UNUSED
;
2666 s
= demand_copy_C_string (&len
);
2668 demand_empty_rest_of_line ();
2671 /* Handle the .purgem pseudo-op. */
2675 int ignore ATTRIBUTE_UNUSED
;
2677 if (is_it_end_of_statement ())
2679 demand_empty_rest_of_line ();
2689 name
= input_line_pointer
;
2690 c
= get_symbol_end ();
2691 delete_macro (name
);
2692 *input_line_pointer
= c
;
2695 while (*input_line_pointer
++ == ',');
2697 --input_line_pointer
;
2698 demand_empty_rest_of_line ();
2701 /* Handle the .rept pseudo-op. */
2705 int ignore ATTRIBUTE_UNUSED
;
2707 as_warn (_(".endr encountered without preceeding .rept, .irc, or .irp"));
2708 demand_empty_rest_of_line ();
2711 /* Handle the .rept pseudo-op. */
2715 int ignore ATTRIBUTE_UNUSED
;
2719 count
= get_absolute_expression ();
2721 do_repeat (count
, "REPT", "ENDR");
2724 /* This function provides a generic repeat block implementation. It allows
2725 different directives to be used as the start/end keys. */
2728 do_repeat (count
, start
, end
)
2737 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2739 as_bad (_("%s without %s"), start
, end
);
2745 sb_add_sb (&many
, &one
);
2749 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2751 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2754 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2755 input buffers to skip. Assumes that conditionals preceding the loop end
2756 are properly nested.
2758 This function makes it easier to implement a premature "break" out of the
2759 loop. The EXTRA arg accounts for other buffers we might have inserted,
2760 such as line substitutions. */
2766 cond_exit_macro (macro_nest
);
2767 while (extra
-- >= 0)
2768 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2771 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2772 this is .equiv, and it is an error if the symbol is already
2779 register char *name
;
2780 register char delim
;
2781 register char *end_name
;
2782 register symbolS
*symbolP
;
2784 /* Especial apologies for the random logic:
2785 this just grew, and could be parsed much more simply!
2787 name
= input_line_pointer
;
2788 delim
= get_symbol_end ();
2789 end_name
= input_line_pointer
;
2792 if (name
== end_name
)
2794 as_bad (_("expected symbol name"));
2795 discard_rest_of_line ();
2801 if (*input_line_pointer
!= ',')
2804 as_bad (_("expected comma after \"%s\""), name
);
2806 ignore_rest_of_line ();
2810 input_line_pointer
++;
2813 if (name
[0] == '.' && name
[1] == '\0')
2815 /* Turn '. = mumble' into a .org mumble. */
2816 register segT segment
;
2819 segment
= get_known_segmented_expression (&exp
);
2822 do_org (segment
, &exp
, 0);
2828 if ((symbolP
= symbol_find (name
)) == NULL
2829 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2832 /* When doing symbol listings, play games with dummy fragments living
2833 outside the normal fragment chain to record the file and line info
2835 if (listing
& LISTING_SYMBOLS
)
2837 extern struct list_info_struct
*listing_tail
;
2838 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2839 memset (dummy_frag
, 0, sizeof (fragS
));
2840 dummy_frag
->fr_type
= rs_fill
;
2841 dummy_frag
->line
= listing_tail
;
2842 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2843 dummy_frag
->fr_symbol
= symbolP
;
2847 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2850 /* "set" symbols are local unless otherwise specified. */
2851 SF_SET_LOCAL (symbolP
);
2852 #endif /* OBJ_COFF */
2855 symbol_table_insert (symbolP
);
2860 && S_IS_DEFINED (symbolP
)
2861 && S_GET_SEGMENT (symbolP
) != reg_section
)
2862 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2864 pseudo_set (symbolP
);
2865 demand_empty_rest_of_line ();
2879 #ifdef md_flush_pending_output
2880 md_flush_pending_output ();
2884 stop
= mri_comment_field (&stopc
);
2886 /* In m68k MRI mode, we need to align to a word boundary, unless
2888 if (flag_m68k_mri
&& mult
> 1)
2890 if (now_seg
== absolute_section
)
2892 abs_section_offset
+= abs_section_offset
& 1;
2893 if (line_label
!= NULL
)
2894 S_SET_VALUE (line_label
, abs_section_offset
);
2896 else if (mri_common_symbol
!= NULL
)
2900 val
= S_GET_VALUE (mri_common_symbol
);
2903 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2904 if (line_label
!= NULL
)
2906 expressionS
*symexp
;
2908 symexp
= symbol_get_value_expression (line_label
);
2909 know (symexp
->X_op
== O_symbol
);
2910 know (symexp
->X_add_symbol
== mri_common_symbol
);
2911 symexp
->X_add_number
+= 1;
2917 do_align (1, (char *) NULL
, 0, 0);
2918 if (line_label
!= NULL
)
2920 symbol_set_frag (line_label
, frag_now
);
2921 S_SET_VALUE (line_label
, frag_now_fix ());
2931 if (*input_line_pointer
== ',')
2933 ++input_line_pointer
;
2938 val
.X_op
= O_constant
;
2939 val
.X_add_number
= 0;
2942 if (val
.X_op
!= O_constant
2943 || val
.X_add_number
< - 0x80
2944 || val
.X_add_number
> 0xff
2945 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2947 if (exp
.X_op
!= O_constant
)
2948 as_bad (_("unsupported variable size or fill value"));
2955 bytes
= mult
* exp
.X_add_number
;
2956 for (i
= 0; i
< exp
.X_add_number
; i
++)
2957 emit_expr (&val
, mult
);
2962 if (exp
.X_op
== O_constant
)
2966 repeat
= exp
.X_add_number
;
2973 as_warn (_(".space repeat count is zero, ignored"));
2974 else if (repeat
< 0)
2975 as_warn (_(".space repeat count is negative, ignored"));
2979 /* If we are in the absolute section, just bump the offset. */
2980 if (now_seg
== absolute_section
)
2982 abs_section_offset
+= repeat
;
2986 /* If we are secretly in an MRI common section, then
2987 creating space just increases the size of the common
2989 if (mri_common_symbol
!= NULL
)
2991 S_SET_VALUE (mri_common_symbol
,
2992 S_GET_VALUE (mri_common_symbol
) + repeat
);
2997 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2998 (offsetT
) repeat
, (char *) 0);
3002 if (now_seg
== absolute_section
)
3004 as_bad (_("space allocation too complex in absolute section"));
3005 subseg_set (text_section
, 0);
3008 if (mri_common_symbol
!= NULL
)
3010 as_bad (_("space allocation too complex in common section"));
3011 mri_common_symbol
= NULL
;
3015 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
3016 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
3020 *p
= val
.X_add_number
;
3025 /* In MRI mode, after an odd number of bytes, we must align to an
3026 even word boundary, unless the next instruction is a dc.b, ds.b
3028 if (flag_mri
&& (bytes
& 1) != 0)
3029 mri_pending_align
= 1;
3031 demand_empty_rest_of_line ();
3034 mri_comment_end (stop
, stopc
);
3037 /* This is like s_space, but the value is a floating point number with
3038 the given precision. This is for the MRI dcb.s pseudo-op and
3042 s_float_space (float_type
)
3047 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3052 stop
= mri_comment_field (&stopc
);
3054 count
= get_absolute_expression ();
3057 if (*input_line_pointer
!= ',')
3059 as_bad (_("missing value"));
3060 ignore_rest_of_line ();
3062 mri_comment_end (stop
, stopc
);
3066 ++input_line_pointer
;
3070 /* Skip any 0{letter} that may be present. Don't even check if the
3071 * letter is legal. */
3072 if (input_line_pointer
[0] == '0'
3073 && ISALPHA (input_line_pointer
[1]))
3074 input_line_pointer
+= 2;
3076 /* Accept :xxxx, where the x's are hex digits, for a floating point
3077 with the exact digits specified. */
3078 if (input_line_pointer
[0] == ':')
3080 flen
= hex_float (float_type
, temp
);
3083 ignore_rest_of_line ();
3085 mri_comment_end (stop
, stopc
);
3093 err
= md_atof (float_type
, temp
, &flen
);
3094 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3098 as_bad (_("bad floating literal: %s"), err
);
3099 ignore_rest_of_line ();
3101 mri_comment_end (stop
, stopc
);
3106 while (--count
>= 0)
3110 p
= frag_more (flen
);
3111 memcpy (p
, temp
, (unsigned int) flen
);
3114 demand_empty_rest_of_line ();
3117 mri_comment_end (stop
, stopc
);
3120 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3124 int ignore ATTRIBUTE_UNUSED
;
3130 stop
= mri_comment_field (&stopc
);
3131 abs_section_offset
= get_absolute_expression ();
3132 subseg_set (absolute_section
, 0);
3133 demand_empty_rest_of_line ();
3135 mri_comment_end (stop
, stopc
);
3140 int ignore ATTRIBUTE_UNUSED
;
3144 temp
= get_absolute_expression ();
3145 subseg_set (text_section
, (subsegT
) temp
);
3146 demand_empty_rest_of_line ();
3148 const_flag
&= ~IN_DEFAULT_SECTION
;
3153 demand_empty_rest_of_line ()
3156 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3157 input_line_pointer
++;
3159 ignore_rest_of_line ();
3161 /* Return having already swallowed end-of-line. */
3165 ignore_rest_of_line ()
3167 /* For suspect lines: gives warning. */
3168 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3170 if (ISPRINT (*input_line_pointer
))
3171 as_warn (_("rest of line ignored; first ignored character is `%c'"),
3172 *input_line_pointer
);
3174 as_warn (_("rest of line ignored; first ignored character valued 0x%x"),
3175 *input_line_pointer
);
3177 while (input_line_pointer
< buffer_limit
3178 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3179 input_line_pointer
++;
3182 input_line_pointer
++;
3184 /* Return pointing just after end-of-line. */
3185 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3189 discard_rest_of_line ()
3191 while (input_line_pointer
< buffer_limit
3192 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3193 input_line_pointer
++;
3195 input_line_pointer
++;
3197 /* Return pointing just after end-of-line. */
3198 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3201 /* In: Pointer to a symbol.
3202 Input_line_pointer->expression.
3204 Out: Input_line_pointer->just after any whitespace after expression.
3205 Tried to set symbol to value of expression.
3206 Will change symbols type, value, and frag; */
3209 pseudo_set (symbolP
)
3213 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3215 #endif /* OBJ_AOUT or OBJ_BOUT */
3217 know (symbolP
); /* NULL pointer is logic error. */
3218 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3219 ext
= S_IS_EXTERNAL (symbolP
);
3220 #endif /* OBJ_AOUT or OBJ_BOUT */
3222 (void) expression (&exp
);
3224 if (exp
.X_op
== O_illegal
)
3225 as_bad (_("illegal expression"));
3226 else if (exp
.X_op
== O_absent
)
3227 as_bad (_("missing expression"));
3228 else if (exp
.X_op
== O_big
)
3230 if (exp
.X_add_number
> 0)
3231 as_bad (_("bignum invalid"));
3233 as_bad (_("floating point number invalid"));
3235 else if (exp
.X_op
== O_subtract
3236 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3237 && (symbol_get_frag (exp
.X_add_symbol
)
3238 == symbol_get_frag (exp
.X_op_symbol
)))
3240 exp
.X_op
= O_constant
;
3241 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3242 - S_GET_VALUE (exp
.X_op_symbol
));
3250 exp
.X_add_number
= 0;
3253 S_SET_SEGMENT (symbolP
, absolute_section
);
3254 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3256 S_SET_EXTERNAL (symbolP
);
3258 S_CLEAR_EXTERNAL (symbolP
);
3259 #endif /* OBJ_AOUT or OBJ_BOUT */
3260 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3261 if (exp
.X_op
!= O_constant
)
3262 symbol_set_frag (symbolP
, &zero_address_frag
);
3266 S_SET_SEGMENT (symbolP
, reg_section
);
3267 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3268 symbol_set_frag (symbolP
, &zero_address_frag
);
3272 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3273 || exp
.X_add_number
!= 0)
3274 symbol_set_value_expression (symbolP
, &exp
);
3275 else if (symbol_section_p (symbolP
))
3276 as_bad ("attempt to set value of section symbol");
3279 symbolS
*s
= exp
.X_add_symbol
;
3281 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3282 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3284 S_SET_EXTERNAL (symbolP
);
3286 S_CLEAR_EXTERNAL (symbolP
);
3287 #endif /* OBJ_AOUT or OBJ_BOUT */
3288 S_SET_VALUE (symbolP
,
3289 exp
.X_add_number
+ S_GET_VALUE (s
));
3290 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3291 copy_symbol_attributes (symbolP
, s
);
3296 /* The value is some complex expression.
3297 FIXME: Should we set the segment to anything? */
3298 symbol_set_value_expression (symbolP
, &exp
);
3305 CONStruct more frag of .bytes, or .words etc.
3306 Should need_pass_2 be 1 then emit no frag(s).
3307 This understands EXPRESSIONS.
3311 This has a split personality. We use expression() to read the
3312 value. We can detect if the value won't fit in a byte or word.
3313 But we can't detect if expression() discarded significant digits
3314 in the case of a long. Not worth the crocks required to fix it. */
3316 /* Select a parser for cons expressions. */
3318 /* Some targets need to parse the expression in various fancy ways.
3319 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3320 (for example, the HPPA does this). Otherwise, you can define
3321 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3322 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3323 are defined, which is the normal case, then only simple expressions
3328 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3331 #ifndef TC_PARSE_CONS_EXPRESSION
3332 #ifdef BITFIELD_CONS_EXPRESSIONS
3333 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3335 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3337 #ifdef REPEAT_CONS_EXPRESSIONS
3338 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3340 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3343 /* If we haven't gotten one yet, just call expression. */
3344 #ifndef TC_PARSE_CONS_EXPRESSION
3345 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3349 /* Worker to do .byte etc statements.
3350 Clobbers input_line_pointer and checks end-of-line. */
3353 cons_worker (nbytes
, rva
)
3354 register int nbytes
; /* 1=.byte, 2=.word, 4=.long. */
3362 #ifdef md_flush_pending_output
3363 md_flush_pending_output ();
3367 stop
= mri_comment_field (&stopc
);
3369 if (is_it_end_of_statement ())
3371 demand_empty_rest_of_line ();
3373 mri_comment_end (stop
, stopc
);
3377 #ifdef md_cons_align
3378 md_cons_align (nbytes
);
3386 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3389 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3393 if (exp
.X_op
== O_symbol
)
3394 exp
.X_op
= O_symbol_rva
;
3396 as_fatal (_("rva without symbol"));
3398 emit_expr (&exp
, (unsigned int) nbytes
);
3401 while (*input_line_pointer
++ == ',');
3403 /* In MRI mode, after an odd number of bytes, we must align to an
3404 even word boundary, unless the next instruction is a dc.b, ds.b
3406 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3407 mri_pending_align
= 1;
3409 input_line_pointer
--; /* Put terminator back into stream. */
3411 demand_empty_rest_of_line ();
3414 mri_comment_end (stop
, stopc
);
3421 cons_worker (size
, 0);
3428 cons_worker (size
, 1);
3431 /* Put the contents of expression EXP into the object file using
3432 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3435 emit_expr (exp
, nbytes
)
3437 unsigned int nbytes
;
3441 valueT extra_digit
= 0;
3443 /* Don't do anything if we are going to make another pass. */
3449 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3450 appear as a four byte positive constant in the .line section,
3451 followed by a 2 byte 0xffff. Look for that case here. */
3453 static int dwarf_line
= -1;
3455 if (strcmp (segment_name (now_seg
), ".line") != 0)
3457 else if (dwarf_line
>= 0
3459 && exp
->X_op
== O_constant
3460 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3461 listing_source_line ((unsigned int) dwarf_line
);
3462 else if (nbytes
== 4
3463 && exp
->X_op
== O_constant
3464 && exp
->X_add_number
>= 0)
3465 dwarf_line
= exp
->X_add_number
;
3470 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3471 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3472 AT_sibling (0x12) followed by a four byte address of the sibling
3473 followed by a 2 byte AT_name (0x38) followed by the name of the
3474 file. We look for that case here. */
3476 static int dwarf_file
= 0;
3478 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3480 else if (dwarf_file
== 0
3482 && exp
->X_op
== O_constant
3483 && exp
->X_add_number
== 0x11)
3485 else if (dwarf_file
== 1
3487 && exp
->X_op
== O_constant
3488 && exp
->X_add_number
== 0x12)
3490 else if (dwarf_file
== 2
3493 else if (dwarf_file
== 3
3495 && exp
->X_op
== O_constant
3496 && exp
->X_add_number
== 0x38)
3501 /* The variable dwarf_file_string tells stringer that the string
3502 may be the name of the source file. */
3503 if (dwarf_file
== 4)
3504 dwarf_file_string
= 1;
3506 dwarf_file_string
= 0;
3511 if (check_eh_frame (exp
, &nbytes
))
3516 /* Allow `.word 0' in the absolute section. */
3517 if (now_seg
== absolute_section
)
3519 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3520 as_bad (_("attempt to store value in absolute section"));
3521 abs_section_offset
+= nbytes
;
3525 /* Handle a negative bignum. */
3527 && exp
->X_add_number
== 0
3528 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3529 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3532 unsigned long carry
;
3534 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3536 /* Negate the bignum: one's complement each digit and add 1. */
3538 for (i
= 0; i
< exp
->X_add_number
; i
++)
3542 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3545 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3546 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3549 /* We can ignore any carry out, because it will be handled by
3550 extra_digit if it is needed. */
3552 extra_digit
= (valueT
) -1;
3556 if (op
== O_absent
|| op
== O_illegal
)
3558 as_warn (_("zero assumed for missing expression"));
3559 exp
->X_add_number
= 0;
3562 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3564 as_bad (_("floating point number invalid"));
3565 exp
->X_add_number
= 0;
3568 else if (op
== O_register
)
3570 as_warn (_("register value used as expression"));
3574 p
= frag_more ((int) nbytes
);
3576 #ifndef WORKING_DOT_WORD
3577 /* If we have the difference of two symbols in a word, save it on
3578 the broken_words list. See the code in write.c. */
3579 if (op
== O_subtract
&& nbytes
== 2)
3581 struct broken_word
*x
;
3583 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3584 x
->next_broken_word
= broken_words
;
3587 x
->subseg
= now_subseg
;
3589 x
->word_goes_here
= p
;
3591 x
->add
= exp
->X_add_symbol
;
3592 x
->sub
= exp
->X_op_symbol
;
3593 x
->addnum
= exp
->X_add_number
;
3601 /* If we have an integer, but the number of bytes is too large to
3602 pass to md_number_to_chars, handle it as a bignum. */
3603 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3608 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3609 extra_digit
= (valueT
) -1;
3610 val
= (valueT
) exp
->X_add_number
;
3614 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3615 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3619 op
= exp
->X_op
= O_big
;
3620 exp
->X_add_number
= gencnt
;
3623 if (op
== O_constant
)
3625 register valueT get
;
3626 register valueT use
;
3627 register valueT mask
;
3629 register valueT unmask
;
3631 /* JF << of >= number of bits in the object is undefined. In
3632 particular SPARC (Sun 4) has problems. */
3633 if (nbytes
>= sizeof (valueT
))
3636 if (nbytes
> sizeof (valueT
))
3639 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3643 /* Don't store these bits. */
3644 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3645 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3648 unmask
= ~mask
; /* Do store these bits. */
3651 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3652 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3655 get
= exp
->X_add_number
;
3657 if ((get
& mask
) != 0
3658 && ((get
& mask
) != mask
3659 || (get
& hibit
) == 0))
3660 { /* Leading bits contain both 0s & 1s. */
3661 as_warn (_("value 0x%lx truncated to 0x%lx"),
3662 (unsigned long) get
, (unsigned long) use
);
3664 /* Put bytes in right order. */
3665 md_number_to_chars (p
, use
, (int) nbytes
);
3667 else if (op
== O_big
)
3670 LITTLENUM_TYPE
*nums
;
3672 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3674 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3677 as_warn (_("bignum truncated to %d bytes"), nbytes
);
3681 if (target_big_endian
)
3683 while (nbytes
> size
)
3685 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3686 nbytes
-= CHARS_PER_LITTLENUM
;
3687 p
+= CHARS_PER_LITTLENUM
;
3690 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3691 while (size
>= CHARS_PER_LITTLENUM
)
3694 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3695 size
-= CHARS_PER_LITTLENUM
;
3696 p
+= CHARS_PER_LITTLENUM
;
3701 nums
= generic_bignum
;
3702 while (size
>= CHARS_PER_LITTLENUM
)
3704 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3706 size
-= CHARS_PER_LITTLENUM
;
3707 p
+= CHARS_PER_LITTLENUM
;
3708 nbytes
-= CHARS_PER_LITTLENUM
;
3711 while (nbytes
>= CHARS_PER_LITTLENUM
)
3713 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3714 nbytes
-= CHARS_PER_LITTLENUM
;
3715 p
+= CHARS_PER_LITTLENUM
;
3721 memset (p
, 0, nbytes
);
3723 /* Now we need to generate a fixS to record the symbol value.
3724 This is easy for BFD. For other targets it can be more
3725 complex. For very complex cases (currently, the HPPA and
3726 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3727 want. For simpler cases, you can define TC_CONS_RELOC to be
3728 the name of the reloc code that should be stored in the fixS.
3729 If neither is defined, the code uses NO_RELOC if it is
3730 defined, and otherwise uses 0. */
3732 #ifdef BFD_ASSEMBLER
3733 #ifdef TC_CONS_FIX_NEW
3734 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3737 bfd_reloc_code_real_type r
;
3754 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3758 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3763 #ifdef TC_CONS_FIX_NEW
3764 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3766 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3767 it is defined, otherwise use NO_RELOC if it is defined,
3769 #ifndef TC_CONS_RELOC
3771 #define TC_CONS_RELOC NO_RELOC
3773 #define TC_CONS_RELOC 0
3776 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3778 #endif /* TC_CONS_FIX_NEW */
3779 #endif /* BFD_ASSEMBLER */
3783 #ifdef BITFIELD_CONS_EXPRESSIONS
3785 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3786 w:x,y:z, where w and y are bitwidths and x and y are values. They
3787 then pack them all together. We do a little better in that we allow
3788 them in words, longs, etc. and we'll pack them in target byte order
3791 The rules are: pack least significat bit first, if a field doesn't
3792 entirely fit, put it in the next unit. Overflowing the bitfield is
3793 explicitly *not* even a warning. The bitwidth should be considered
3796 To use this function the tc-XXX.h file should define
3797 BITFIELD_CONS_EXPRESSIONS. */
3800 parse_bitfield_cons (exp
, nbytes
)
3802 unsigned int nbytes
;
3804 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3805 char *hold
= input_line_pointer
;
3807 (void) expression (exp
);
3809 if (*input_line_pointer
== ':')
3816 unsigned long width
;
3818 if (*input_line_pointer
!= ':')
3820 input_line_pointer
= hold
;
3822 } /* Next piece is not a bitfield. */
3824 /* In the general case, we can't allow
3825 full expressions with symbol
3826 differences and such. The relocation
3827 entries for symbols not defined in this
3828 assembly would require arbitrary field
3829 widths, positions, and masks which most
3830 of our current object formats don't
3833 In the specific case where a symbol
3834 *is* defined in this assembly, we
3835 *could* build fixups and track it, but
3836 this could lead to confusion for the
3837 backends. I'm lazy. I'll take any
3838 SEG_ABSOLUTE. I think that means that
3839 you can use a previous .set or
3840 .equ type symbol. xoxorich. */
3842 if (exp
->X_op
== O_absent
)
3844 as_warn (_("using a bit field width of zero"));
3845 exp
->X_add_number
= 0;
3846 exp
->X_op
= O_constant
;
3847 } /* Implied zero width bitfield. */
3849 if (exp
->X_op
!= O_constant
)
3851 *input_line_pointer
= '\0';
3852 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3853 *input_line_pointer
= ':';
3854 demand_empty_rest_of_line ();
3856 } /* Too complex. */
3858 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3860 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3861 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3862 width
= BITS_PER_CHAR
* nbytes
;
3865 if (width
> bits_available
)
3867 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3868 input_line_pointer
= hold
;
3869 exp
->X_add_number
= value
;
3874 hold
= ++input_line_pointer
;
3876 (void) expression (exp
);
3877 if (exp
->X_op
!= O_constant
)
3879 char cache
= *input_line_pointer
;
3881 *input_line_pointer
= '\0';
3882 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3883 *input_line_pointer
= cache
;
3884 demand_empty_rest_of_line ();
3886 } /* Too complex. */
3888 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3889 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3891 if ((bits_available
-= width
) == 0
3892 || is_it_end_of_statement ()
3893 || *input_line_pointer
!= ',')
3896 } /* All the bitfields we're gonna get. */
3898 hold
= ++input_line_pointer
;
3899 (void) expression (exp
);
3902 exp
->X_add_number
= value
;
3903 exp
->X_op
= O_constant
;
3904 exp
->X_unsigned
= 1;
3908 #endif /* BITFIELD_CONS_EXPRESSIONS */
3910 /* Handle an MRI style string expression. */
3914 parse_mri_cons (exp
, nbytes
)
3916 unsigned int nbytes
;
3918 if (*input_line_pointer
!= '\''
3919 && (input_line_pointer
[1] != '\''
3920 || (*input_line_pointer
!= 'A'
3921 && *input_line_pointer
!= 'E')))
3922 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3926 unsigned int result
= 0;
3928 /* An MRI style string. Cut into as many bytes as will fit into
3929 a nbyte chunk, left justify if necessary, and separate with
3930 commas so we can try again later. */
3931 if (*input_line_pointer
== 'A')
3932 ++input_line_pointer
;
3933 else if (*input_line_pointer
== 'E')
3935 as_bad (_("EBCDIC constants are not supported"));
3936 ++input_line_pointer
;
3939 input_line_pointer
++;
3940 for (scan
= 0; scan
< nbytes
; scan
++)
3942 if (*input_line_pointer
== '\'')
3944 if (input_line_pointer
[1] == '\'')
3946 input_line_pointer
++;
3951 result
= (result
<< 8) | (*input_line_pointer
++);
3955 while (scan
< nbytes
)
3961 /* Create correct expression. */
3962 exp
->X_op
= O_constant
;
3963 exp
->X_add_number
= result
;
3965 /* Fake it so that we can read the next char too. */
3966 if (input_line_pointer
[0] != '\'' ||
3967 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3969 input_line_pointer
-= 2;
3970 input_line_pointer
[0] = ',';
3971 input_line_pointer
[1] = '\'';
3974 input_line_pointer
++;
3977 #endif /* TC_M68K */
3979 #ifdef REPEAT_CONS_EXPRESSIONS
3981 /* Parse a repeat expression for cons. This is used by the MIPS
3982 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3983 object file COUNT times.
3985 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3988 parse_repeat_cons (exp
, nbytes
)
3990 unsigned int nbytes
;
3997 if (*input_line_pointer
!= ':')
3999 /* No repeat count. */
4003 ++input_line_pointer
;
4004 expression (&count
);
4005 if (count
.X_op
!= O_constant
4006 || count
.X_add_number
<= 0)
4008 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4012 /* The cons function is going to output this expression once. So we
4013 output it count - 1 times. */
4014 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
4015 emit_expr (exp
, nbytes
);
4018 #endif /* REPEAT_CONS_EXPRESSIONS */
4020 /* Parse a floating point number represented as a hex constant. This
4021 permits users to specify the exact bits they want in the floating
4025 hex_float (float_type
, bytes
)
4059 as_bad (_("unknown floating type type '%c'"), float_type
);
4063 /* It would be nice if we could go through expression to parse the
4064 hex constant, but if we get a bignum it's a pain to sort it into
4065 the buffer correctly. */
4067 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4071 /* The MRI assembler accepts arbitrary underscores strewn about
4072 through the hex constant, so we ignore them as well. */
4073 if (*input_line_pointer
== '_')
4075 ++input_line_pointer
;
4081 as_warn (_("floating point constant too large"));
4084 d
= hex_value (*input_line_pointer
) << 4;
4085 ++input_line_pointer
;
4086 while (*input_line_pointer
== '_')
4087 ++input_line_pointer
;
4088 if (hex_p (*input_line_pointer
))
4090 d
+= hex_value (*input_line_pointer
);
4091 ++input_line_pointer
;
4093 if (target_big_endian
)
4096 bytes
[length
- i
- 1] = d
;
4102 if (target_big_endian
)
4103 memset (bytes
+ i
, 0, length
- i
);
4105 memset (bytes
, 0, length
- i
);
4113 CONStruct some more frag chars of .floats .ffloats etc.
4114 Makes 0 or more new frags.
4115 If need_pass_2 == 1, no frags are emitted.
4116 This understands only floating literals, not expressions. Sorry.
4118 A floating constant is defined by atof_generic(), except it is preceded
4119 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4120 reading, I decided to be incompatible. This always tries to give you
4121 rounded bits to the precision of the pseudo-op. Former AS did premature
4122 truncatation, restored noisy bits instead of trailing 0s AND gave you
4123 a choice of 2 flavours of noise according to which of 2 floating-point
4124 scanners you directed AS to use.
4126 In: input_line_pointer->whitespace before, or '0' of flonum. */
4129 float_cons (float_type
)
4130 /* Clobbers input_line-pointer, checks end-of-line. */
4131 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4134 int length
; /* Number of chars in an object. */
4135 register char *err
; /* Error from scanning floating literal. */
4136 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4138 if (is_it_end_of_statement ())
4140 demand_empty_rest_of_line ();
4144 #ifdef md_flush_pending_output
4145 md_flush_pending_output ();
4150 /* input_line_pointer->1st char of a flonum (we hope!). */
4153 /* Skip any 0{letter} that may be present. Don't even check if the
4154 letter is legal. Someone may invent a "z" format and this routine
4155 has no use for such information. Lusers beware: you get
4156 diagnostics if your input is ill-conditioned. */
4157 if (input_line_pointer
[0] == '0'
4158 && ISALPHA (input_line_pointer
[1]))
4159 input_line_pointer
+= 2;
4161 /* Accept :xxxx, where the x's are hex digits, for a floating
4162 point with the exact digits specified. */
4163 if (input_line_pointer
[0] == ':')
4165 ++input_line_pointer
;
4166 length
= hex_float (float_type
, temp
);
4169 ignore_rest_of_line ();
4175 err
= md_atof (float_type
, temp
, &length
);
4176 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4180 as_bad (_("bad floating literal: %s"), err
);
4181 ignore_rest_of_line ();
4192 #ifdef REPEAT_CONS_EXPRESSIONS
4193 if (*input_line_pointer
== ':')
4195 expressionS count_exp
;
4197 ++input_line_pointer
;
4198 expression (&count_exp
);
4200 if (count_exp
.X_op
!= O_constant
4201 || count_exp
.X_add_number
<= 0)
4202 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4204 count
= count_exp
.X_add_number
;
4208 while (--count
>= 0)
4210 p
= frag_more (length
);
4211 memcpy (p
, temp
, (unsigned int) length
);
4216 while (*input_line_pointer
++ == ',');
4218 /* Put terminator back into stream. */
4219 --input_line_pointer
;
4220 demand_empty_rest_of_line ();
4223 /* Return the size of a LEB128 value. */
4226 sizeof_sleb128 (value
)
4229 register int size
= 0;
4230 register unsigned byte
;
4234 byte
= (value
& 0x7f);
4235 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4236 Fortunately, we can structure things so that the extra work reduces
4237 to a noop on systems that do things "properly". */
4238 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4241 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4242 || ((value
== -1) && ((byte
& 0x40) != 0))));
4248 sizeof_uleb128 (value
)
4251 register int size
= 0;
4252 register unsigned byte
;
4256 byte
= (value
& 0x7f);
4266 sizeof_leb128 (value
, sign
)
4271 return sizeof_sleb128 ((offsetT
) value
);
4273 return sizeof_uleb128 (value
);
4276 /* Output a LEB128 value. */
4279 output_sleb128 (p
, value
)
4283 register char *orig
= p
;
4288 unsigned byte
= (value
& 0x7f);
4290 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4291 Fortunately, we can structure things so that the extra work reduces
4292 to a noop on systems that do things "properly". */
4293 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4295 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4296 || ((value
== -1) && ((byte
& 0x40) != 0))));
4308 output_uleb128 (p
, value
)
4316 unsigned byte
= (value
& 0x7f);
4319 /* More bytes to follow. */
4330 output_leb128 (p
, value
, sign
)
4336 return output_sleb128 (p
, (offsetT
) value
);
4338 return output_uleb128 (p
, value
);
4341 /* Do the same for bignums. We combine sizeof with output here in that
4342 we don't output for NULL values of P. It isn't really as critical as
4343 for "normal" values that this be streamlined. */
4346 output_big_sleb128 (p
, bignum
, size
)
4348 LITTLENUM_TYPE
*bignum
;
4356 /* Strip leading sign extensions off the bignum. */
4357 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4362 if (loaded
< 7 && size
> 0)
4364 val
|= (*bignum
<< loaded
);
4365 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4376 if ((val
== 0 && (byte
& 0x40) == 0)
4377 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4378 && (byte
& 0x40) != 0))
4386 while (byte
& 0x80);
4392 output_big_uleb128 (p
, bignum
, size
)
4394 LITTLENUM_TYPE
*bignum
;
4402 /* Strip leading zeros off the bignum. */
4403 /* XXX: Is this needed? */
4404 while (size
> 0 && bignum
[size
- 1] == 0)
4409 if (loaded
< 7 && size
> 0)
4411 val
|= (*bignum
<< loaded
);
4412 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4421 if (size
> 0 || val
)
4428 while (byte
& 0x80);
4434 output_big_leb128 (p
, bignum
, size
, sign
)
4436 LITTLENUM_TYPE
*bignum
;
4440 return output_big_sleb128 (p
, bignum
, size
);
4442 return output_big_uleb128 (p
, bignum
, size
);
4445 /* Generate the appropriate fragments for a given expression to emit a
4449 emit_leb128_expr (exp
, sign
)
4453 operatorT op
= exp
->X_op
;
4456 if (op
== O_absent
|| op
== O_illegal
)
4458 as_warn (_("zero assumed for missing expression"));
4459 exp
->X_add_number
= 0;
4462 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4464 as_bad (_("floating point number invalid"));
4465 exp
->X_add_number
= 0;
4468 else if (op
== O_register
)
4470 as_warn (_("register value used as expression"));
4474 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
4475 a signal that this is leb128 data. It shouldn't optimize this away. */
4477 if (check_eh_frame (exp
, &nbytes
))
4480 /* Let the backend know that subsequent data may be byte aligned. */
4481 #ifdef md_cons_align
4485 if (op
== O_constant
)
4487 /* If we've got a constant, emit the thing directly right now. */
4489 valueT value
= exp
->X_add_number
;
4493 size
= sizeof_leb128 (value
, sign
);
4494 p
= frag_more (size
);
4495 output_leb128 (p
, value
, sign
);
4497 else if (op
== O_big
)
4499 /* O_big is a different sort of constant. */
4504 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4505 p
= frag_more (size
);
4506 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4510 /* Otherwise, we have to create a variable sized fragment and
4511 resolve things later. */
4513 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4514 make_expr_symbol (exp
), 0, (char *) NULL
);
4518 /* Parse the .sleb128 and .uleb128 pseudos. */
4529 emit_leb128_expr (&exp
, sign
);
4531 while (*input_line_pointer
++ == ',');
4533 input_line_pointer
--;
4534 demand_empty_rest_of_line ();
4537 /* We read 0 or more ',' separated, double-quoted strings.
4538 Caller should have checked need_pass_2 is FALSE because we don't
4542 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4543 /* Checks end-of-line. */
4544 register int append_zero
; /* 0: don't append '\0', else 1. */
4546 register unsigned int c
;
4549 #ifdef md_flush_pending_output
4550 md_flush_pending_output ();
4553 /* The following awkward logic is to parse ZERO or more strings,
4554 comma separated. Recall a string expression includes spaces
4555 before the opening '\"' and spaces after the closing '\"'.
4556 We fake a leading ',' if there is (supposed to be)
4557 a 1st, expression. We keep demanding expressions for each ','. */
4558 if (is_it_end_of_statement ())
4560 c
= 0; /* Skip loop. */
4561 ++input_line_pointer
; /* Compensate for end of loop. */
4565 c
= ','; /* Do loop. */
4567 /* If we have been switched into the abs_section then we
4568 will not have an obstack onto which we can hang strings. */
4569 if (now_seg
== absolute_section
)
4571 as_bad (_("strings must be placed into a section"));
4573 ignore_rest_of_line ();
4576 while (c
== ',' || c
== '<' || c
== '"')
4579 switch (*input_line_pointer
)
4582 ++input_line_pointer
; /*->1st char of string. */
4583 start
= input_line_pointer
;
4584 while (is_a_char (c
= next_char_of_string ()))
4586 FRAG_APPEND_1_CHAR (c
);
4590 FRAG_APPEND_1_CHAR (0);
4592 know (input_line_pointer
[-1] == '\"');
4596 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4597 will emit .string with a filename in the .debug section
4598 after a sequence of constants. See the comment in
4599 emit_expr for the sequence. emit_expr will set
4600 dwarf_file_string to non-zero if this string might be a
4601 source file name. */
4602 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4603 dwarf_file_string
= 0;
4604 else if (dwarf_file_string
)
4606 c
= input_line_pointer
[-1];
4607 input_line_pointer
[-1] = '\0';
4608 listing_source_file (start
);
4609 input_line_pointer
[-1] = c
;
4616 input_line_pointer
++;
4617 c
= get_single_number ();
4618 FRAG_APPEND_1_CHAR (c
);
4619 if (*input_line_pointer
!= '>')
4621 as_bad (_("expected <nn>"));
4623 input_line_pointer
++;
4626 input_line_pointer
++;
4630 c
= *input_line_pointer
;
4633 demand_empty_rest_of_line ();
4636 /* FIXME-SOMEDAY: I had trouble here on characters with the
4637 high bits set. We'll probably also have trouble with
4638 multibyte chars, wide chars, etc. Also be careful about
4639 returning values bigger than 1 byte. xoxorich. */
4642 next_char_of_string ()
4644 register unsigned int c
;
4646 c
= *input_line_pointer
++ & CHAR_MASK
;
4654 as_warn (_("unterminated string; newline inserted"));
4655 bump_line_counters ();
4658 #ifndef NO_STRING_ESCAPES
4660 switch (c
= *input_line_pointer
++)
4688 break; /* As itself. */
4704 for (i
= 0, number
= 0;
4705 ISDIGIT (c
) && i
< 3;
4706 c
= *input_line_pointer
++, i
++)
4708 number
= number
* 8 + c
- '0';
4713 --input_line_pointer
;
4722 c
= *input_line_pointer
++;
4723 while (ISXDIGIT (c
))
4726 number
= number
* 16 + c
- '0';
4727 else if (ISUPPER (c
))
4728 number
= number
* 16 + c
- 'A' + 10;
4730 number
= number
* 16 + c
- 'a' + 10;
4731 c
= *input_line_pointer
++;
4734 --input_line_pointer
;
4739 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4740 as_warn (_("unterminated string; newline inserted"));
4742 bump_line_counters ();
4747 #ifdef ONLY_STANDARD_ESCAPES
4748 as_bad (_("bad escaped character in string"));
4750 #endif /* ONLY_STANDARD_ESCAPES */
4755 #endif /* ! defined (NO_STRING_ESCAPES) */
4764 get_segmented_expression (expP
)
4765 register expressionS
*expP
;
4767 register segT retval
;
4769 retval
= expression (expP
);
4770 if (expP
->X_op
== O_illegal
4771 || expP
->X_op
== O_absent
4772 || expP
->X_op
== O_big
)
4774 as_bad (_("expected address expression"));
4775 expP
->X_op
= O_constant
;
4776 expP
->X_add_number
= 0;
4777 retval
= absolute_section
;
4783 get_known_segmented_expression (expP
)
4784 register expressionS
*expP
;
4786 register segT retval
;
4788 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4790 /* There is no easy way to extract the undefined symbol from the
4792 if (expP
->X_add_symbol
!= NULL
4793 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4794 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4795 S_GET_NAME (expP
->X_add_symbol
));
4797 as_warn (_("some symbol undefined; zero assumed"));
4798 retval
= absolute_section
;
4799 expP
->X_op
= O_constant
;
4800 expP
->X_add_number
= 0;
4802 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4807 get_absolute_expr (exp
)
4811 if (exp
->X_op
!= O_constant
)
4813 if (exp
->X_op
!= O_absent
)
4814 as_bad (_("bad or irreducible absolute expression"));
4815 exp
->X_add_number
= 0;
4817 return exp
->X_add_number
;
4821 get_absolute_expression ()
4825 return get_absolute_expr (&exp
);
4828 char /* Return terminator. */
4829 get_absolute_expression_and_terminator (val_pointer
)
4830 long *val_pointer
; /* Return value of expression. */
4832 /* FIXME: val_pointer should probably be offsetT *. */
4833 *val_pointer
= (long) get_absolute_expression ();
4834 return (*input_line_pointer
++);
4837 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4838 Give a warning if that happens. */
4841 demand_copy_C_string (len_pointer
)
4846 if ((s
= demand_copy_string (len_pointer
)) != 0)
4850 for (len
= *len_pointer
; len
> 0; len
--)
4857 as_bad (_("this string may not contain \'\\0\'"));
4865 /* Demand string, but return a safe (=private) copy of the string.
4866 Return NULL if we can't read a string here. */
4869 demand_copy_string (lenP
)
4872 register unsigned int c
;
4878 if (*input_line_pointer
== '\"')
4880 input_line_pointer
++; /* Skip opening quote. */
4882 while (is_a_char (c
= next_char_of_string ()))
4884 obstack_1grow (¬es
, c
);
4887 /* JF this next line is so demand_copy_C_string will return a
4888 null terminated string. */
4889 obstack_1grow (¬es
, '\0');
4890 retval
= obstack_finish (¬es
);
4894 as_warn (_("missing string"));
4896 ignore_rest_of_line ();
4902 /* In: Input_line_pointer->next character.
4904 Do: Skip input_line_pointer over all whitespace.
4906 Out: 1 if input_line_pointer->end-of-line. */
4909 is_it_end_of_statement ()
4912 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4916 equals (sym_name
, reassign
)
4920 register symbolS
*symbolP
; /* Symbol we are working with. */
4924 input_line_pointer
++;
4925 if (*input_line_pointer
== '=')
4926 input_line_pointer
++;
4928 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4929 input_line_pointer
++;
4932 stop
= mri_comment_field (&stopc
);
4934 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4936 /* Turn '. = mumble' into a .org mumble. */
4937 register segT segment
;
4940 segment
= get_known_segmented_expression (&exp
);
4942 do_org (segment
, &exp
, 0);
4949 symbolP
= symbol_find (sym_name
);
4950 local
= symbolP
== NULL
;
4952 #endif /* OBJ_COFF */
4953 symbolP
= symbol_find_or_make (sym_name
);
4954 /* Permit register names to be redefined. */
4956 && S_IS_DEFINED (symbolP
)
4957 && S_GET_SEGMENT (symbolP
) != reg_section
)
4958 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
4961 /* "set" symbols are local unless otherwise specified. */
4963 SF_SET_LOCAL (symbolP
);
4964 #endif /* OBJ_COFF */
4966 pseudo_set (symbolP
);
4971 /* Check garbage after the expression. */
4972 ignore_rest_of_line ();
4973 mri_comment_end (stop
, stopc
);
4977 /* .incbin -- include a file verbatim at the current location. */
4981 int x ATTRIBUTE_UNUSED
;
4992 #ifdef md_flush_pending_output
4993 md_flush_pending_output ();
4997 filename
= demand_copy_string (& len
);
4998 if (filename
== NULL
)
5003 /* Look for optional skip and count. */
5004 if (* input_line_pointer
== ',')
5006 ++ input_line_pointer
;
5007 skip
= get_absolute_expression ();
5011 if (* input_line_pointer
== ',')
5013 ++ input_line_pointer
;
5015 count
= get_absolute_expression ();
5017 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
5023 demand_empty_rest_of_line ();
5025 /* Try opening absolute path first, then try include dirs. */
5026 binfile
= fopen (filename
, FOPEN_RB
);
5027 if (binfile
== NULL
)
5031 path
= xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
5033 for (i
= 0; i
< include_dir_count
; i
++)
5035 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
5037 binfile
= fopen (path
, FOPEN_RB
);
5038 if (binfile
!= NULL
)
5042 if (binfile
== NULL
)
5043 as_bad (_("file not found: %s"), filename
);
5046 path
= xstrdup (filename
);
5052 register_dependency (path
);
5054 /* Compute the length of the file. */
5055 if (fseek (binfile
, 0, SEEK_END
) != 0)
5057 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
5060 file_len
= ftell (binfile
);
5062 /* If a count was not specified use the size of the file. */
5066 if (skip
+ count
> file_len
)
5068 as_bad (_("skip (%ld) + count (%ld) larger than file size (%ld)"),
5069 skip
, count
, file_len
);
5073 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
5075 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
5079 /* Allocate frag space and store file contents in it. */
5080 binfrag
= frag_more (count
);
5082 bytes
= fread (binfrag
, 1, count
, binfile
);
5084 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5085 path
, bytes
, count
);
5088 if (binfile
!= NULL
)
5094 /* .include -- include a file at this point. */
5098 int arg ATTRIBUTE_UNUSED
;
5107 filename
= demand_copy_string (&i
);
5108 if (filename
== NULL
)
5110 /* demand_copy_string has already printed an error and
5111 called ignore_rest_of_line. */
5119 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5120 && *input_line_pointer
!= ' '
5121 && *input_line_pointer
!= '\t')
5123 obstack_1grow (¬es
, *input_line_pointer
);
5124 ++input_line_pointer
;
5128 obstack_1grow (¬es
, '\0');
5129 filename
= obstack_finish (¬es
);
5130 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5131 ++input_line_pointer
;
5134 demand_empty_rest_of_line ();
5135 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
5137 for (i
= 0; i
< include_dir_count
; i
++)
5139 strcpy (path
, include_dirs
[i
]);
5141 strcat (path
, filename
);
5142 if (0 != (try = fopen (path
, FOPEN_RT
)))
5152 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5153 register_dependency (path
);
5154 input_scrub_insert_file (path
);
5158 add_include_dir (path
)
5163 if (include_dir_count
== 0)
5165 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5166 include_dirs
[0] = "."; /* Current dir. */
5167 include_dir_count
= 2;
5171 include_dir_count
++;
5173 (char **) realloc (include_dirs
,
5174 include_dir_count
* sizeof (*include_dirs
));
5177 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5180 if (i
> include_dir_maxlen
)
5181 include_dir_maxlen
= i
;
5184 /* Output debugging information to denote the source file. */
5187 generate_file_debug ()
5189 if (debug_type
== DEBUG_STABS
)
5190 stabs_generate_asm_file ();
5193 /* Output line number debugging information for the current source line. */
5196 generate_lineno_debug ()
5200 case DEBUG_UNSPECIFIED
:
5205 stabs_generate_asm_lineno ();
5208 ecoff_generate_asm_lineno ();
5211 /* ??? We could here indicate to dwarf2dbg.c that something
5212 has changed. However, since there is additional backend
5213 support that is required (calling dwarf2_emit_insn), we
5214 let dwarf2dbg.c call as_where on its own. */
5219 /* Output debugging information to mark a function entry point or end point.
5220 END_P is zero for .func, and non-zero for .endfunc. */
5226 do_s_func (end_p
, NULL
);
5229 /* Subroutine of s_func so targets can choose a different default prefix.
5230 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5233 do_s_func (end_p
, default_prefix
)
5235 const char *default_prefix
;
5237 /* Record the current function so that we can issue an error message for
5238 misplaced .func,.endfunc, and also so that .endfunc needs no
5240 static char *current_name
;
5241 static char *current_label
;
5245 if (current_name
== NULL
)
5247 as_bad (_("missing .func"));
5248 ignore_rest_of_line ();
5252 if (debug_type
== DEBUG_STABS
)
5253 stabs_generate_asm_endfunc (current_name
, current_label
);
5255 current_name
= current_label
= NULL
;
5260 char delim1
, delim2
;
5262 if (current_name
!= NULL
)
5264 as_bad (_(".endfunc missing for previous .func"));
5265 ignore_rest_of_line ();
5269 name
= input_line_pointer
;
5270 delim1
= get_symbol_end ();
5271 name
= xstrdup (name
);
5272 *input_line_pointer
= delim1
;
5274 if (*input_line_pointer
!= ',')
5277 asprintf (&label
, "%s%s", default_prefix
, name
);
5280 char leading_char
= 0;
5281 #ifdef BFD_ASSEMBLER
5282 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5284 /* Missing entry point, use function's name with the leading
5287 asprintf (&label
, "%c%s", leading_char
, name
);
5294 ++input_line_pointer
;
5296 label
= input_line_pointer
;
5297 delim2
= get_symbol_end ();
5298 label
= xstrdup (label
);
5299 *input_line_pointer
= delim2
;
5302 if (debug_type
== DEBUG_STABS
)
5303 stabs_generate_asm_func (name
, label
);
5305 current_name
= name
;
5306 current_label
= label
;
5309 demand_empty_rest_of_line ();
5314 int arg ATTRIBUTE_UNUSED
;
5316 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5318 ++input_line_pointer
;
5320 ++input_line_pointer
;
5324 read_print_statistics (file
)
5327 hash_print_statistics (file
, "pseudo-op table", po_hash
);
5330 /* Inserts the given line into the input stream.
5332 This call avoids macro/conditionals nesting checking, since the contents of
5333 the line are assumed to replace the contents of a line already scanned.
5335 An appropriate use of this function would be substition of input lines when
5336 called by md_start_line_hook(). The given line is assumed to already be
5337 properly scrubbed. */
5340 input_scrub_insert_line (line
)
5345 sb_add_string (&newline
, line
);
5346 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
5348 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
5351 /* Insert a file into the input stream; the path must resolve to an actual
5352 file; no include path searching or dependency registering is performed. */
5355 input_scrub_insert_file (path
)
5358 input_scrub_include_file (path
, input_line_pointer
);
5359 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);