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 (%lu) out of range ignored"),
1393 (unsigned long) temp
);
1394 ignore_rest_of_line ();
1396 mri_comment_end (stop
, stopc
);
1401 symbolP
= symbol_find_or_make (name
);
1404 if (S_IS_DEFINED (symbolP
) && !S_IS_COMMON (symbolP
))
1406 as_bad (_("symbol `%s' is already defined"),
1407 S_GET_NAME (symbolP
));
1408 ignore_rest_of_line ();
1410 mri_comment_end (stop
, stopc
);
1414 if (S_GET_VALUE (symbolP
))
1416 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1417 as_bad (_("length of .comm \"%s\" is already %ld; not changing to %ld"),
1418 S_GET_NAME (symbolP
),
1419 (long) S_GET_VALUE (symbolP
),
1424 S_SET_VALUE (symbolP
, (valueT
) temp
);
1425 S_SET_EXTERNAL (symbolP
);
1429 extern int flag_one
;
1430 if (!temp
|| !flag_one
)
1431 S_GET_OTHER(symbolP
) = const_flag
;
1433 #endif /* not OBJ_VMS */
1434 know (symbolP
->sy_frag
== &zero_address_frag
);
1436 demand_empty_rest_of_line ();
1439 mri_comment_end (stop
, stopc
);
1442 /* The MRI COMMON pseudo-op. We handle this by creating a common
1443 symbol with the appropriate name. We make s_space do the right
1444 thing by increasing the size. */
1447 s_mri_common (small
)
1448 int small ATTRIBUTE_UNUSED
;
1464 stop
= mri_comment_field (&stopc
);
1468 name
= input_line_pointer
;
1469 if (!ISDIGIT (*name
))
1470 c
= get_symbol_end ();
1475 ++input_line_pointer
;
1477 while (ISDIGIT (*input_line_pointer
));
1479 c
= *input_line_pointer
;
1480 *input_line_pointer
= '\0';
1482 if (line_label
!= NULL
)
1484 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1485 + (input_line_pointer
- name
)
1487 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1492 sym
= symbol_find_or_make (name
);
1493 *input_line_pointer
= c
;
1497 if (*input_line_pointer
!= ',')
1501 ++input_line_pointer
;
1502 align
= get_absolute_expression ();
1505 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1507 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1508 ignore_rest_of_line ();
1509 mri_comment_end (stop
, stopc
);
1513 S_SET_EXTERNAL (sym
);
1514 mri_common_symbol
= sym
;
1518 S_SET_ALIGN (sym
, align
);
1521 if (line_label
!= NULL
)
1524 exp
.X_op
= O_symbol
;
1525 exp
.X_add_symbol
= sym
;
1526 exp
.X_add_number
= 0;
1527 symbol_set_value_expression (line_label
, &exp
);
1528 symbol_set_frag (line_label
, &zero_address_frag
);
1529 S_SET_SEGMENT (line_label
, expr_section
);
1532 /* FIXME: We just ignore the small argument, which distinguishes
1533 COMMON and COMMON.S. I don't know what we can do about it. */
1535 /* Ignore the type and hptype. */
1536 if (*input_line_pointer
== ',')
1537 input_line_pointer
+= 2;
1538 if (*input_line_pointer
== ',')
1539 input_line_pointer
+= 2;
1541 demand_empty_rest_of_line ();
1543 mri_comment_end (stop
, stopc
);
1548 int ignore ATTRIBUTE_UNUSED
;
1553 temp
= get_absolute_expression ();
1554 if (flag_readonly_data_in_text
)
1556 section
= text_section
;
1560 section
= data_section
;
1562 subseg_set (section
, (subsegT
) temp
);
1567 demand_empty_rest_of_line ();
1570 /* Handle the .appfile pseudo-op. This is automatically generated by
1571 do_scrub_chars when a preprocessor # line comment is seen with a
1572 file name. This default definition may be overridden by the object
1573 or CPU specific pseudo-ops. This function is also the default
1574 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1578 s_app_file_string (file
)
1583 listing_source_file (file
);
1585 register_dependency (file
);
1587 obj_app_file (file
);
1592 s_app_file (appfile
)
1598 /* Some assemblers tolerate immediately following '"'. */
1599 if ((s
= demand_copy_string (&length
)) != 0)
1601 /* If this is a fake .appfile, a fake newline was inserted into
1602 the buffer. Passing -2 to new_logical_line tells it to
1605 = (!new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1607 /* In MRI mode, the preprocessor may have inserted an extraneous
1610 && *input_line_pointer
== '\''
1611 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1612 ++input_line_pointer
;
1614 demand_empty_rest_of_line ();
1616 s_app_file_string (s
);
1620 /* Handle the .appline pseudo-op. This is automatically generated by
1621 do_scrub_chars when a preprocessor # line comment is seen. This
1622 default definition may be overridden by the object or CPU specific
1627 int ignore ATTRIBUTE_UNUSED
;
1631 /* The given number is that of the next line. */
1632 l
= get_absolute_expression () - 1;
1634 /* Some of the back ends can't deal with non-positive line numbers.
1635 Besides, it's silly. */
1636 as_warn (_("line numbers must be positive; line number %d rejected"),
1640 new_logical_line ((char *) NULL
, l
);
1643 listing_source_line (l
);
1646 demand_empty_rest_of_line ();
1649 /* Handle the .end pseudo-op. Actually, the real work is done in
1650 read_a_source_file. */
1654 int ignore ATTRIBUTE_UNUSED
;
1658 /* The MRI assembler permits the start symbol to follow .end,
1659 but we don't support that. */
1661 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
1662 && *input_line_pointer
!= '*'
1663 && *input_line_pointer
!= '!')
1664 as_warn (_("start address not supported"));
1668 /* Handle the .err pseudo-op. */
1672 int ignore ATTRIBUTE_UNUSED
;
1674 as_bad (_(".err encountered"));
1675 demand_empty_rest_of_line ();
1678 /* Handle the MRI fail pseudo-op. */
1682 int ignore ATTRIBUTE_UNUSED
;
1689 stop
= mri_comment_field (&stopc
);
1691 temp
= get_absolute_expression ();
1693 as_warn (_(".fail %ld encountered"), (long) temp
);
1695 as_bad (_(".fail %ld encountered"), (long) temp
);
1697 demand_empty_rest_of_line ();
1700 mri_comment_end (stop
, stopc
);
1705 int ignore ATTRIBUTE_UNUSED
;
1707 expressionS rep_exp
;
1709 register long fill
= 0;
1712 #ifdef md_flush_pending_output
1713 md_flush_pending_output ();
1716 get_known_segmented_expression (&rep_exp
);
1717 if (*input_line_pointer
== ',')
1719 input_line_pointer
++;
1720 size
= get_absolute_expression ();
1721 if (*input_line_pointer
== ',')
1723 input_line_pointer
++;
1724 fill
= get_absolute_expression ();
1728 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1729 #define BSD_FILL_SIZE_CROCK_8 (8)
1730 if (size
> BSD_FILL_SIZE_CROCK_8
)
1732 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
1733 size
= BSD_FILL_SIZE_CROCK_8
;
1737 as_warn (_("size negative; .fill ignored"));
1740 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1742 if (rep_exp
.X_add_number
< 0)
1743 as_warn (_("repeat < 0; .fill ignored"));
1747 if (size
&& !need_pass_2
)
1749 if (rep_exp
.X_op
== O_constant
)
1751 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1752 (relax_substateT
) 0, (symbolS
*) 0,
1753 (offsetT
) rep_exp
.X_add_number
,
1758 /* We don't have a constant repeat count, so we can't use
1759 rs_fill. We can get the same results out of rs_space,
1760 but its argument is in bytes, so we must multiply the
1761 repeat count by size. */
1764 rep_sym
= make_expr_symbol (&rep_exp
);
1767 expressionS size_exp
;
1768 size_exp
.X_op
= O_constant
;
1769 size_exp
.X_add_number
= size
;
1771 rep_exp
.X_op
= O_multiply
;
1772 rep_exp
.X_add_symbol
= rep_sym
;
1773 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1774 rep_exp
.X_add_number
= 0;
1775 rep_sym
= make_expr_symbol (&rep_exp
);
1778 p
= frag_var (rs_space
, (int) size
, (int) size
,
1779 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1782 memset (p
, 0, (unsigned int) size
);
1784 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1785 flavoured AS. The following bizarre behaviour is to be
1786 compatible with above. I guess they tried to take up to 8
1787 bytes from a 4-byte expression and they forgot to sign
1789 #define BSD_FILL_SIZE_CROCK_4 (4)
1790 md_number_to_chars (p
, (valueT
) fill
,
1791 (size
> BSD_FILL_SIZE_CROCK_4
1792 ? BSD_FILL_SIZE_CROCK_4
1794 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1795 but emits no error message because it seems a legal thing to do.
1796 It is a degenerate case of .fill but could be emitted by a
1799 demand_empty_rest_of_line ();
1804 int ignore ATTRIBUTE_UNUSED
;
1813 stop
= mri_comment_field (&stopc
);
1817 name
= input_line_pointer
;
1818 c
= get_symbol_end ();
1819 symbolP
= symbol_find_or_make (name
);
1820 S_SET_EXTERNAL (symbolP
);
1822 *input_line_pointer
= c
;
1824 c
= *input_line_pointer
;
1827 input_line_pointer
++;
1829 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1835 demand_empty_rest_of_line ();
1838 mri_comment_end (stop
, stopc
);
1841 /* Handle the MRI IRP and IRPC pseudo-ops. */
1853 as_where (&file
, &line
);
1856 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1857 sb_add_char (&s
, *input_line_pointer
++);
1861 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
);
1863 as_bad_where (file
, line
, "%s", err
);
1867 input_scrub_include_sb (&out
, input_line_pointer
, 1);
1869 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1872 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1873 the section to only be linked once. However, this is not supported
1874 by most object file formats. This takes an optional argument,
1875 which is what to do about duplicates. */
1879 int ignore ATTRIBUTE_UNUSED
;
1881 enum linkonce_type type
;
1885 type
= LINKONCE_DISCARD
;
1887 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1892 s
= input_line_pointer
;
1893 c
= get_symbol_end ();
1894 if (strcasecmp (s
, "discard") == 0)
1895 type
= LINKONCE_DISCARD
;
1896 else if (strcasecmp (s
, "one_only") == 0)
1897 type
= LINKONCE_ONE_ONLY
;
1898 else if (strcasecmp (s
, "same_size") == 0)
1899 type
= LINKONCE_SAME_SIZE
;
1900 else if (strcasecmp (s
, "same_contents") == 0)
1901 type
= LINKONCE_SAME_CONTENTS
;
1903 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1905 *input_line_pointer
= c
;
1908 #ifdef obj_handle_link_once
1909 obj_handle_link_once (type
);
1910 #else /* ! defined (obj_handle_link_once) */
1911 #ifdef BFD_ASSEMBLER
1915 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1916 as_warn (_(".linkonce is not supported for this object file format"));
1918 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1919 flags
|= SEC_LINK_ONCE
;
1924 case LINKONCE_DISCARD
:
1925 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1927 case LINKONCE_ONE_ONLY
:
1928 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1930 case LINKONCE_SAME_SIZE
:
1931 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1933 case LINKONCE_SAME_CONTENTS
:
1934 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1937 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1938 as_bad (_("bfd_set_section_flags: %s"),
1939 bfd_errmsg (bfd_get_error ()));
1941 #else /* ! defined (BFD_ASSEMBLER) */
1942 as_warn (_(".linkonce is not supported for this object file format"));
1943 #endif /* ! defined (BFD_ASSEMBLER) */
1944 #endif /* ! defined (obj_handle_link_once) */
1946 demand_empty_rest_of_line ();
1950 s_lcomm_internal (needs_align
, bytes_p
)
1951 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1952 (alignment); 0 if it was an ".lcomm" (2 args only). */
1954 /* 1 if the alignment value should be interpreted as the byte boundary,
1955 rather than the power of 2. */
1958 register char *name
;
1962 register symbolS
*symbolP
;
1963 segT current_seg
= now_seg
;
1964 subsegT current_subseg
= now_subseg
;
1965 const int max_alignment
= 15;
1967 segT bss_seg
= bss_section
;
1969 name
= input_line_pointer
;
1970 c
= get_symbol_end ();
1971 p
= input_line_pointer
;
1976 as_bad (_("expected symbol name"));
1977 discard_rest_of_line ();
1983 /* Accept an optional comma after the name. The comma used to be
1984 required, but Irix 5 cc does not generate it. */
1985 if (*input_line_pointer
== ',')
1987 ++input_line_pointer
;
1991 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1993 as_bad (_("missing size expression"));
1997 if ((temp
= get_absolute_expression ()) < 0)
1999 as_warn (_("BSS length (%d) < 0 ignored"), temp
);
2000 ignore_rest_of_line ();
2004 #if defined (TC_MIPS) || defined (TC_ALPHA)
2005 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
2006 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
2008 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
2009 if ((unsigned) temp
<= bfd_get_gp_size (stdoutput
))
2011 bss_seg
= subseg_new (".sbss", 1);
2012 seg_info (bss_seg
)->bss
= 1;
2013 #ifdef BFD_ASSEMBLER
2014 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
2015 as_warn (_("error setting flags for \".sbss\": %s"),
2016 bfd_errmsg (bfd_get_error ()));
2024 TC_IMPLICIT_LCOMM_ALIGNMENT (temp
, align
);
2026 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
2028 record_alignment (bss_seg
, align
);
2036 if (*input_line_pointer
!= ',')
2038 as_bad (_("expected comma after size"));
2039 ignore_rest_of_line ();
2043 input_line_pointer
++;
2046 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2048 as_bad (_("missing alignment"));
2052 align
= get_absolute_expression ();
2056 /* Convert to a power of 2. */
2061 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2064 as_bad (_("alignment not a power of 2"));
2069 if (align
> max_alignment
)
2071 align
= max_alignment
;
2072 as_warn (_("alignment too large; %d assumed"), align
);
2077 as_warn (_("alignment negative; 0 assumed"));
2080 record_alignment (bss_seg
, align
);
2084 /* Assume some objects may require alignment on some systems. */
2085 #if defined (TC_ALPHA) && ! defined (VMS)
2088 align
= ffs (temp
) - 1;
2089 if (temp
% (1 << align
))
2096 symbolP
= symbol_find_or_make (name
);
2100 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2101 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2102 #ifdef BFD_ASSEMBLER
2103 (OUTPUT_FLAVOR
!= bfd_target_aout_flavour
2104 || (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0)) &&
2106 (S_GET_OTHER (symbolP
) == 0 && S_GET_DESC (symbolP
) == 0) &&
2109 (S_GET_SEGMENT (symbolP
) == bss_seg
2110 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2114 subseg_set (bss_seg
, 1);
2117 frag_align (align
, 0, 0);
2119 /* Detach from old frag. */
2120 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2121 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2123 symbol_set_frag (symbolP
, frag_now
);
2124 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, symbolP
,
2125 (offsetT
) temp
, (char *) 0);
2128 S_SET_SEGMENT (symbolP
, bss_seg
);
2131 /* The symbol may already have been created with a preceding
2132 ".globl" directive -- be careful not to step on storage class
2133 in that case. Otherwise, set it to static. */
2134 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2136 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2138 #endif /* OBJ_COFF */
2141 S_SET_SIZE (symbolP
, temp
);
2145 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2147 subseg_set (current_seg
, current_subseg
);
2149 demand_empty_rest_of_line ();
2153 s_lcomm (needs_align
)
2156 s_lcomm_internal (needs_align
, 0);
2160 s_lcomm_bytes (needs_align
)
2163 s_lcomm_internal (needs_align
, 1);
2168 int ignore ATTRIBUTE_UNUSED
;
2170 register char *name
;
2174 register symbolS
*symbolP
;
2176 /* We permit ANY defined expression: BSD4.2 demands constants. */
2177 name
= input_line_pointer
;
2178 c
= get_symbol_end ();
2179 p
= input_line_pointer
;
2184 as_bad (_("expected symbol name"));
2185 discard_rest_of_line ();
2191 if (*input_line_pointer
!= ',')
2194 as_bad (_("expected comma after \"%s\""), name
);
2196 ignore_rest_of_line ();
2200 input_line_pointer
++;
2203 if (exp
.X_op
!= O_constant
2204 && exp
.X_op
!= O_register
)
2206 as_bad (_("bad expression"));
2207 ignore_rest_of_line ();
2212 symbolP
= symbol_find_or_make (name
);
2214 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2215 symbolP->sy_desc == 0) out of this test because coff doesn't have
2216 those fields, and I can't see when they'd ever be tripped. I
2217 don't think I understand why they were here so I may have
2218 introduced a bug. As recently as 1.37 didn't have this test
2219 anyway. xoxorich. */
2221 if (S_GET_SEGMENT (symbolP
) == undefined_section
2222 && S_GET_VALUE (symbolP
) == 0)
2224 /* The name might be an undefined .global symbol; be sure to
2225 keep the "external" bit. */
2226 S_SET_SEGMENT (symbolP
,
2227 (exp
.X_op
== O_constant
2230 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2234 as_bad (_("symbol `%s' is already defined"), name
);
2238 demand_empty_rest_of_line ();
2241 /* Read a line into an sb. Returns the character that ended the line
2242 or zero if there are no more lines. */
2248 char quote1
, quote2
, inquote
;
2251 if (input_line_pointer
[-1] == '\n')
2252 bump_line_counters ();
2254 if (input_line_pointer
>= buffer_limit
)
2256 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2257 if (buffer_limit
== 0)
2261 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2262 code needs to be changed. */
2271 #ifdef LEX_IS_STRINGQUOTE
2277 while ((c
= * input_line_pointer
++) != 0
2278 && (!is_end_of_line
[c
]
2279 || (inquote
!= '\0' && c
!= '\n')))
2283 else if (inquote
== '\0')
2287 else if (c
== quote2
)
2291 sb_add_char (line
, c
);
2294 /* Don't skip multiple end-of-line characters, because that breaks support
2295 for the IA-64 stop bit (;;) which looks like two consecutive end-of-line
2296 characters but isn't. Instead just skip one end of line character and
2297 return the character skipped so that the caller can re-insert it if
2302 /* Define a macro. This is an interface to macro.c. */
2306 int ignore ATTRIBUTE_UNUSED
;
2315 as_where (&file
, &line
);
2318 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2319 sb_add_char (&s
, *input_line_pointer
++);
2322 if (line_label
!= NULL
)
2323 sb_add_string (&label
, S_GET_NAME (line_label
));
2325 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2327 as_bad_where (file
, line
, "%s", err
);
2330 if (line_label
!= NULL
)
2332 S_SET_SEGMENT (line_label
, undefined_section
);
2333 S_SET_VALUE (line_label
, 0);
2334 symbol_set_frag (line_label
, &zero_address_frag
);
2337 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2338 && hash_find (po_hash
, name
) != NULL
)
2341 && hash_find (po_hash
, name
+ 1) != NULL
))
2342 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2349 /* Handle the .mexit pseudo-op, which immediately exits a macro
2354 int ignore ATTRIBUTE_UNUSED
;
2356 cond_exit_macro (macro_nest
);
2357 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2360 /* Switch in and out of MRI mode. */
2364 int ignore ATTRIBUTE_UNUSED
;
2368 on
= get_absolute_expression ();
2369 old_flag
= flag_mri
;
2387 /* Operator precedence changes in m68k MRI mode, so we need to
2388 update the operator rankings. */
2389 expr_set_precedence ();
2391 #ifdef MRI_MODE_CHANGE
2393 MRI_MODE_CHANGE (on
);
2396 demand_empty_rest_of_line ();
2399 /* Handle changing the location counter. */
2402 do_org (segment
, exp
, fill
)
2407 if (segment
!= now_seg
&& segment
!= absolute_section
)
2408 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2410 if (now_seg
== absolute_section
)
2413 as_warn (_("ignoring fill value in absolute section"));
2414 if (exp
->X_op
!= O_constant
)
2416 as_bad (_("only constant offsets supported in absolute section"));
2417 exp
->X_add_number
= 0;
2419 abs_section_offset
= exp
->X_add_number
;
2424 symbolS
*sym
= exp
->X_add_symbol
;
2425 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2427 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2429 /* Handle complex expressions. */
2430 sym
= make_expr_symbol (exp
);
2434 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2441 int ignore ATTRIBUTE_UNUSED
;
2443 register segT segment
;
2445 register long temp_fill
;
2447 #ifdef md_flush_pending_output
2448 md_flush_pending_output ();
2451 /* The m68k MRI assembler has a different meaning for .org. It
2452 means to create an absolute section at a given address. We can't
2453 support that--use a linker script instead. */
2456 as_bad (_("MRI style ORG pseudo-op not supported"));
2457 ignore_rest_of_line ();
2461 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2462 thing as a sub-segment-relative origin. Any absolute origin is
2463 given a warning, then assumed to be segment-relative. Any
2464 segmented origin expression ("foo+42") had better be in the right
2465 segment or the .org is ignored.
2467 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2468 we never know sub-segment sizes when we are reading code. BSD
2469 will crash trying to emit negative numbers of filler bytes in
2470 certain .orgs. We don't crash, but see as-write for that code.
2472 Don't make frag if need_pass_2==1. */
2473 segment
= get_known_segmented_expression (&exp
);
2474 if (*input_line_pointer
== ',')
2476 input_line_pointer
++;
2477 temp_fill
= get_absolute_expression ();
2483 do_org (segment
, &exp
, temp_fill
);
2485 demand_empty_rest_of_line ();
2488 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2489 called by the obj-format routine which handles section changing
2490 when in MRI mode. It will create a new section, and return it. It
2491 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2492 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2493 flags will be set in the section. */
2497 char *type ATTRIBUTE_UNUSED
;
2507 name
= input_line_pointer
;
2508 if (!ISDIGIT (*name
))
2509 c
= get_symbol_end ();
2514 ++input_line_pointer
;
2516 while (ISDIGIT (*input_line_pointer
));
2518 c
= *input_line_pointer
;
2519 *input_line_pointer
= '\0';
2522 name
= xstrdup (name
);
2524 *input_line_pointer
= c
;
2526 seg
= subseg_new (name
, 0);
2528 if (*input_line_pointer
== ',')
2532 ++input_line_pointer
;
2533 align
= get_absolute_expression ();
2534 record_alignment (seg
, align
);
2538 if (*input_line_pointer
== ',')
2540 c
= *++input_line_pointer
;
2542 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2545 as_bad (_("unrecognized section type"));
2546 ++input_line_pointer
;
2548 #ifdef BFD_ASSEMBLER
2552 flags
= SEC_NO_FLAGS
;
2554 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2555 else if (*type
== 'D' || *type
== 'M')
2556 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2557 else if (*type
== 'R')
2558 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2559 if (flags
!= SEC_NO_FLAGS
)
2561 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2562 as_warn (_("error setting flags for \"%s\": %s"),
2563 bfd_section_name (stdoutput
, seg
),
2564 bfd_errmsg (bfd_get_error ()));
2570 /* Ignore the HP type. */
2571 if (*input_line_pointer
== ',')
2572 input_line_pointer
+= 2;
2574 demand_empty_rest_of_line ();
2576 #else /* ! TC_M68K */
2585 name
= input_line_pointer
;
2586 c
= get_symbol_end ();
2588 name
= xstrdup (name
);
2590 *input_line_pointer
= c
;
2592 seg
= subseg_new (name
, 0);
2594 if (*input_line_pointer
!= ',')
2600 ++input_line_pointer
;
2602 sectype
= input_line_pointer
;
2603 c
= get_symbol_end ();
2604 if (*sectype
== '\0')
2606 else if (strcasecmp (sectype
, "text") == 0)
2608 else if (strcasecmp (sectype
, "data") == 0)
2610 else if (strcasecmp (sectype
, "romdata") == 0)
2613 as_warn (_("unrecognized section type `%s'"), sectype
);
2614 *input_line_pointer
= c
;
2617 if (*input_line_pointer
== ',')
2621 ++input_line_pointer
;
2623 seccmd
= input_line_pointer
;
2624 c
= get_symbol_end ();
2625 if (strcasecmp (seccmd
, "absolute") == 0)
2627 as_bad (_("absolute sections are not supported"));
2628 *input_line_pointer
= c
;
2629 ignore_rest_of_line ();
2632 else if (strcasecmp (seccmd
, "align") == 0)
2636 *input_line_pointer
= c
;
2637 align
= get_absolute_expression ();
2638 record_alignment (seg
, align
);
2642 as_warn (_("unrecognized section command `%s'"), seccmd
);
2643 *input_line_pointer
= c
;
2647 demand_empty_rest_of_line ();
2649 #else /* ! TC_I960 */
2650 /* The MRI assembler seems to use different forms of .sect for
2651 different targets. */
2652 as_bad ("MRI mode not supported for this target");
2653 ignore_rest_of_line ();
2654 #endif /* ! TC_I960 */
2655 #endif /* ! TC_M68K */
2658 /* Handle the .print pseudo-op. */
2662 int ignore ATTRIBUTE_UNUSED
;
2667 s
= demand_copy_C_string (&len
);
2669 demand_empty_rest_of_line ();
2672 /* Handle the .purgem pseudo-op. */
2676 int ignore ATTRIBUTE_UNUSED
;
2678 if (is_it_end_of_statement ())
2680 demand_empty_rest_of_line ();
2690 name
= input_line_pointer
;
2691 c
= get_symbol_end ();
2692 delete_macro (name
);
2693 *input_line_pointer
= c
;
2696 while (*input_line_pointer
++ == ',');
2698 --input_line_pointer
;
2699 demand_empty_rest_of_line ();
2702 /* Handle the .rept pseudo-op. */
2706 int ignore ATTRIBUTE_UNUSED
;
2708 as_warn (_(".endr encountered without preceeding .rept, .irc, or .irp"));
2709 demand_empty_rest_of_line ();
2712 /* Handle the .rept pseudo-op. */
2716 int ignore ATTRIBUTE_UNUSED
;
2720 count
= get_absolute_expression ();
2722 do_repeat (count
, "REPT", "ENDR");
2725 /* This function provides a generic repeat block implementation. It allows
2726 different directives to be used as the start/end keys. */
2729 do_repeat (count
, start
, end
)
2738 if (!buffer_and_nest (start
, end
, &one
, get_line_sb
))
2740 as_bad (_("%s without %s"), start
, end
);
2746 sb_add_sb (&many
, &one
);
2750 input_scrub_include_sb (&many
, input_line_pointer
, 1);
2752 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2755 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2756 input buffers to skip. Assumes that conditionals preceding the loop end
2757 are properly nested.
2759 This function makes it easier to implement a premature "break" out of the
2760 loop. The EXTRA arg accounts for other buffers we might have inserted,
2761 such as line substitutions. */
2767 cond_exit_macro (macro_nest
);
2768 while (extra
-- >= 0)
2769 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2772 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2773 this is .equiv, and it is an error if the symbol is already
2780 register char *name
;
2781 register char delim
;
2782 register char *end_name
;
2783 register symbolS
*symbolP
;
2785 /* Especial apologies for the random logic:
2786 this just grew, and could be parsed much more simply!
2788 name
= input_line_pointer
;
2789 delim
= get_symbol_end ();
2790 end_name
= input_line_pointer
;
2793 if (name
== end_name
)
2795 as_bad (_("expected symbol name"));
2796 discard_rest_of_line ();
2802 if (*input_line_pointer
!= ',')
2805 as_bad (_("expected comma after \"%s\""), name
);
2807 ignore_rest_of_line ();
2811 input_line_pointer
++;
2814 if (name
[0] == '.' && name
[1] == '\0')
2816 /* Turn '. = mumble' into a .org mumble. */
2817 register segT segment
;
2820 segment
= get_known_segmented_expression (&exp
);
2823 do_org (segment
, &exp
, 0);
2829 if ((symbolP
= symbol_find (name
)) == NULL
2830 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2833 /* When doing symbol listings, play games with dummy fragments living
2834 outside the normal fragment chain to record the file and line info
2836 if (listing
& LISTING_SYMBOLS
)
2838 extern struct list_info_struct
*listing_tail
;
2839 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof (fragS
));
2840 memset (dummy_frag
, 0, sizeof (fragS
));
2841 dummy_frag
->fr_type
= rs_fill
;
2842 dummy_frag
->line
= listing_tail
;
2843 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2844 dummy_frag
->fr_symbol
= symbolP
;
2848 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2851 /* "set" symbols are local unless otherwise specified. */
2852 SF_SET_LOCAL (symbolP
);
2853 #endif /* OBJ_COFF */
2856 symbol_table_insert (symbolP
);
2861 && S_IS_DEFINED (symbolP
)
2862 && S_GET_SEGMENT (symbolP
) != reg_section
)
2863 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
2865 pseudo_set (symbolP
);
2866 demand_empty_rest_of_line ();
2880 #ifdef md_flush_pending_output
2881 md_flush_pending_output ();
2885 stop
= mri_comment_field (&stopc
);
2887 /* In m68k MRI mode, we need to align to a word boundary, unless
2889 if (flag_m68k_mri
&& mult
> 1)
2891 if (now_seg
== absolute_section
)
2893 abs_section_offset
+= abs_section_offset
& 1;
2894 if (line_label
!= NULL
)
2895 S_SET_VALUE (line_label
, abs_section_offset
);
2897 else if (mri_common_symbol
!= NULL
)
2901 val
= S_GET_VALUE (mri_common_symbol
);
2904 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2905 if (line_label
!= NULL
)
2907 expressionS
*symexp
;
2909 symexp
= symbol_get_value_expression (line_label
);
2910 know (symexp
->X_op
== O_symbol
);
2911 know (symexp
->X_add_symbol
== mri_common_symbol
);
2912 symexp
->X_add_number
+= 1;
2918 do_align (1, (char *) NULL
, 0, 0);
2919 if (line_label
!= NULL
)
2921 symbol_set_frag (line_label
, frag_now
);
2922 S_SET_VALUE (line_label
, frag_now_fix ());
2932 if (*input_line_pointer
== ',')
2934 ++input_line_pointer
;
2939 val
.X_op
= O_constant
;
2940 val
.X_add_number
= 0;
2943 if (val
.X_op
!= O_constant
2944 || val
.X_add_number
< - 0x80
2945 || val
.X_add_number
> 0xff
2946 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2948 if (exp
.X_op
!= O_constant
)
2949 as_bad (_("unsupported variable size or fill value"));
2956 bytes
= mult
* exp
.X_add_number
;
2957 for (i
= 0; i
< exp
.X_add_number
; i
++)
2958 emit_expr (&val
, mult
);
2963 if (exp
.X_op
== O_constant
)
2967 repeat
= exp
.X_add_number
;
2974 as_warn (_(".space repeat count is zero, ignored"));
2975 else if (repeat
< 0)
2976 as_warn (_(".space repeat count is negative, ignored"));
2980 /* If we are in the absolute section, just bump the offset. */
2981 if (now_seg
== absolute_section
)
2983 abs_section_offset
+= repeat
;
2987 /* If we are secretly in an MRI common section, then
2988 creating space just increases the size of the common
2990 if (mri_common_symbol
!= NULL
)
2992 S_SET_VALUE (mri_common_symbol
,
2993 S_GET_VALUE (mri_common_symbol
) + repeat
);
2998 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2999 (offsetT
) repeat
, (char *) 0);
3003 if (now_seg
== absolute_section
)
3005 as_bad (_("space allocation too complex in absolute section"));
3006 subseg_set (text_section
, 0);
3009 if (mri_common_symbol
!= NULL
)
3011 as_bad (_("space allocation too complex in common section"));
3012 mri_common_symbol
= NULL
;
3016 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
3017 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
3021 *p
= val
.X_add_number
;
3026 /* In MRI mode, after an odd number of bytes, we must align to an
3027 even word boundary, unless the next instruction is a dc.b, ds.b
3029 if (flag_mri
&& (bytes
& 1) != 0)
3030 mri_pending_align
= 1;
3032 demand_empty_rest_of_line ();
3035 mri_comment_end (stop
, stopc
);
3038 /* This is like s_space, but the value is a floating point number with
3039 the given precision. This is for the MRI dcb.s pseudo-op and
3043 s_float_space (float_type
)
3048 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3053 stop
= mri_comment_field (&stopc
);
3055 count
= get_absolute_expression ();
3058 if (*input_line_pointer
!= ',')
3060 as_bad (_("missing value"));
3061 ignore_rest_of_line ();
3063 mri_comment_end (stop
, stopc
);
3067 ++input_line_pointer
;
3071 /* Skip any 0{letter} that may be present. Don't even check if the
3072 * letter is legal. */
3073 if (input_line_pointer
[0] == '0'
3074 && ISALPHA (input_line_pointer
[1]))
3075 input_line_pointer
+= 2;
3077 /* Accept :xxxx, where the x's are hex digits, for a floating point
3078 with the exact digits specified. */
3079 if (input_line_pointer
[0] == ':')
3081 flen
= hex_float (float_type
, temp
);
3084 ignore_rest_of_line ();
3086 mri_comment_end (stop
, stopc
);
3094 err
= md_atof (float_type
, temp
, &flen
);
3095 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3099 as_bad (_("bad floating literal: %s"), err
);
3100 ignore_rest_of_line ();
3102 mri_comment_end (stop
, stopc
);
3107 while (--count
>= 0)
3111 p
= frag_more (flen
);
3112 memcpy (p
, temp
, (unsigned int) flen
);
3115 demand_empty_rest_of_line ();
3118 mri_comment_end (stop
, stopc
);
3121 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3125 int ignore ATTRIBUTE_UNUSED
;
3131 stop
= mri_comment_field (&stopc
);
3132 abs_section_offset
= get_absolute_expression ();
3133 subseg_set (absolute_section
, 0);
3134 demand_empty_rest_of_line ();
3136 mri_comment_end (stop
, stopc
);
3141 int ignore ATTRIBUTE_UNUSED
;
3145 temp
= get_absolute_expression ();
3146 subseg_set (text_section
, (subsegT
) temp
);
3147 demand_empty_rest_of_line ();
3149 const_flag
&= ~IN_DEFAULT_SECTION
;
3154 demand_empty_rest_of_line ()
3157 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3158 input_line_pointer
++;
3160 ignore_rest_of_line ();
3162 /* Return having already swallowed end-of-line. */
3166 ignore_rest_of_line ()
3168 /* For suspect lines: gives warning. */
3169 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3171 if (ISPRINT (*input_line_pointer
))
3172 as_warn (_("rest of line ignored; first ignored character is `%c'"),
3173 *input_line_pointer
);
3175 as_warn (_("rest of line ignored; first ignored character valued 0x%x"),
3176 *input_line_pointer
);
3178 while (input_line_pointer
< buffer_limit
3179 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3180 input_line_pointer
++;
3183 input_line_pointer
++;
3185 /* Return pointing just after end-of-line. */
3186 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3190 discard_rest_of_line ()
3192 while (input_line_pointer
< buffer_limit
3193 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3194 input_line_pointer
++;
3196 input_line_pointer
++;
3198 /* Return pointing just after end-of-line. */
3199 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3202 /* In: Pointer to a symbol.
3203 Input_line_pointer->expression.
3205 Out: Input_line_pointer->just after any whitespace after expression.
3206 Tried to set symbol to value of expression.
3207 Will change symbols type, value, and frag; */
3210 pseudo_set (symbolP
)
3214 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3216 #endif /* OBJ_AOUT or OBJ_BOUT */
3218 know (symbolP
); /* NULL pointer is logic error. */
3219 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3220 ext
= S_IS_EXTERNAL (symbolP
);
3221 #endif /* OBJ_AOUT or OBJ_BOUT */
3223 (void) expression (&exp
);
3225 if (exp
.X_op
== O_illegal
)
3226 as_bad (_("illegal expression"));
3227 else if (exp
.X_op
== O_absent
)
3228 as_bad (_("missing expression"));
3229 else if (exp
.X_op
== O_big
)
3231 if (exp
.X_add_number
> 0)
3232 as_bad (_("bignum invalid"));
3234 as_bad (_("floating point number invalid"));
3236 else if (exp
.X_op
== O_subtract
3237 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3238 && (symbol_get_frag (exp
.X_add_symbol
)
3239 == symbol_get_frag (exp
.X_op_symbol
)))
3241 exp
.X_op
= O_constant
;
3242 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3243 - S_GET_VALUE (exp
.X_op_symbol
));
3251 exp
.X_add_number
= 0;
3254 S_SET_SEGMENT (symbolP
, absolute_section
);
3255 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3257 S_SET_EXTERNAL (symbolP
);
3259 S_CLEAR_EXTERNAL (symbolP
);
3260 #endif /* OBJ_AOUT or OBJ_BOUT */
3261 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3262 if (exp
.X_op
!= O_constant
)
3263 symbol_set_frag (symbolP
, &zero_address_frag
);
3267 S_SET_SEGMENT (symbolP
, reg_section
);
3268 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3269 symbol_set_frag (symbolP
, &zero_address_frag
);
3273 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3274 || exp
.X_add_number
!= 0)
3275 symbol_set_value_expression (symbolP
, &exp
);
3276 else if (symbol_section_p (symbolP
))
3277 as_bad ("attempt to set value of section symbol");
3280 symbolS
*s
= exp
.X_add_symbol
;
3282 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3283 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3285 S_SET_EXTERNAL (symbolP
);
3287 S_CLEAR_EXTERNAL (symbolP
);
3288 #endif /* OBJ_AOUT or OBJ_BOUT */
3289 S_SET_VALUE (symbolP
,
3290 exp
.X_add_number
+ S_GET_VALUE (s
));
3291 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3292 copy_symbol_attributes (symbolP
, s
);
3297 /* The value is some complex expression.
3298 FIXME: Should we set the segment to anything? */
3299 symbol_set_value_expression (symbolP
, &exp
);
3306 CONStruct more frag of .bytes, or .words etc.
3307 Should need_pass_2 be 1 then emit no frag(s).
3308 This understands EXPRESSIONS.
3312 This has a split personality. We use expression() to read the
3313 value. We can detect if the value won't fit in a byte or word.
3314 But we can't detect if expression() discarded significant digits
3315 in the case of a long. Not worth the crocks required to fix it. */
3317 /* Select a parser for cons expressions. */
3319 /* Some targets need to parse the expression in various fancy ways.
3320 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3321 (for example, the HPPA does this). Otherwise, you can define
3322 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3323 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3324 are defined, which is the normal case, then only simple expressions
3329 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3332 #ifndef TC_PARSE_CONS_EXPRESSION
3333 #ifdef BITFIELD_CONS_EXPRESSIONS
3334 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3336 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3338 #ifdef REPEAT_CONS_EXPRESSIONS
3339 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3341 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3344 /* If we haven't gotten one yet, just call expression. */
3345 #ifndef TC_PARSE_CONS_EXPRESSION
3346 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3351 do_parse_cons_expression (expressionS
*exp
, int nbytes
)
3353 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3357 /* Worker to do .byte etc statements.
3358 Clobbers input_line_pointer and checks end-of-line. */
3361 cons_worker (nbytes
, rva
)
3362 register int nbytes
; /* 1=.byte, 2=.word, 4=.long. */
3370 #ifdef md_flush_pending_output
3371 md_flush_pending_output ();
3375 stop
= mri_comment_field (&stopc
);
3377 if (is_it_end_of_statement ())
3379 demand_empty_rest_of_line ();
3381 mri_comment_end (stop
, stopc
);
3385 #ifdef md_cons_align
3386 md_cons_align (nbytes
);
3394 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3397 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3401 if (exp
.X_op
== O_symbol
)
3402 exp
.X_op
= O_symbol_rva
;
3404 as_fatal (_("rva without symbol"));
3406 emit_expr (&exp
, (unsigned int) nbytes
);
3409 while (*input_line_pointer
++ == ',');
3411 /* In MRI mode, after an odd number of bytes, we must align to an
3412 even word boundary, unless the next instruction is a dc.b, ds.b
3414 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3415 mri_pending_align
= 1;
3417 input_line_pointer
--; /* Put terminator back into stream. */
3419 demand_empty_rest_of_line ();
3422 mri_comment_end (stop
, stopc
);
3429 cons_worker (size
, 0);
3436 cons_worker (size
, 1);
3439 /* Put the contents of expression EXP into the object file using
3440 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3443 emit_expr (exp
, nbytes
)
3445 unsigned int nbytes
;
3449 valueT extra_digit
= 0;
3451 /* Don't do anything if we are going to make another pass. */
3455 dot_value
= frag_now_fix ();
3459 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3460 appear as a four byte positive constant in the .line section,
3461 followed by a 2 byte 0xffff. Look for that case here. */
3463 static int dwarf_line
= -1;
3465 if (strcmp (segment_name (now_seg
), ".line") != 0)
3467 else if (dwarf_line
>= 0
3469 && exp
->X_op
== O_constant
3470 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3471 listing_source_line ((unsigned int) dwarf_line
);
3472 else if (nbytes
== 4
3473 && exp
->X_op
== O_constant
3474 && exp
->X_add_number
>= 0)
3475 dwarf_line
= exp
->X_add_number
;
3480 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3481 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3482 AT_sibling (0x12) followed by a four byte address of the sibling
3483 followed by a 2 byte AT_name (0x38) followed by the name of the
3484 file. We look for that case here. */
3486 static int dwarf_file
= 0;
3488 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3490 else if (dwarf_file
== 0
3492 && exp
->X_op
== O_constant
3493 && exp
->X_add_number
== 0x11)
3495 else if (dwarf_file
== 1
3497 && exp
->X_op
== O_constant
3498 && exp
->X_add_number
== 0x12)
3500 else if (dwarf_file
== 2
3503 else if (dwarf_file
== 3
3505 && exp
->X_op
== O_constant
3506 && exp
->X_add_number
== 0x38)
3511 /* The variable dwarf_file_string tells stringer that the string
3512 may be the name of the source file. */
3513 if (dwarf_file
== 4)
3514 dwarf_file_string
= 1;
3516 dwarf_file_string
= 0;
3521 if (check_eh_frame (exp
, &nbytes
))
3526 /* Allow `.word 0' in the absolute section. */
3527 if (now_seg
== absolute_section
)
3529 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3530 as_bad (_("attempt to store value in absolute section"));
3531 abs_section_offset
+= nbytes
;
3535 /* Handle a negative bignum. */
3537 && exp
->X_add_number
== 0
3538 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3539 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3542 unsigned long carry
;
3544 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3546 /* Negate the bignum: one's complement each digit and add 1. */
3548 for (i
= 0; i
< exp
->X_add_number
; i
++)
3552 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
3555 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3556 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3559 /* We can ignore any carry out, because it will be handled by
3560 extra_digit if it is needed. */
3562 extra_digit
= (valueT
) -1;
3566 if (op
== O_absent
|| op
== O_illegal
)
3568 as_warn (_("zero assumed for missing expression"));
3569 exp
->X_add_number
= 0;
3572 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3574 as_bad (_("floating point number invalid"));
3575 exp
->X_add_number
= 0;
3578 else if (op
== O_register
)
3580 as_warn (_("register value used as expression"));
3584 p
= frag_more ((int) nbytes
);
3586 #ifndef WORKING_DOT_WORD
3587 /* If we have the difference of two symbols in a word, save it on
3588 the broken_words list. See the code in write.c. */
3589 if (op
== O_subtract
&& nbytes
== 2)
3591 struct broken_word
*x
;
3593 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3594 x
->next_broken_word
= broken_words
;
3597 x
->subseg
= now_subseg
;
3599 x
->word_goes_here
= p
;
3601 x
->add
= exp
->X_add_symbol
;
3602 x
->sub
= exp
->X_op_symbol
;
3603 x
->addnum
= exp
->X_add_number
;
3611 /* If we have an integer, but the number of bytes is too large to
3612 pass to md_number_to_chars, handle it as a bignum. */
3613 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3618 if (!exp
->X_unsigned
&& exp
->X_add_number
< 0)
3619 extra_digit
= (valueT
) -1;
3620 val
= (valueT
) exp
->X_add_number
;
3624 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3625 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3629 op
= exp
->X_op
= O_big
;
3630 exp
->X_add_number
= gencnt
;
3633 if (op
== O_constant
)
3635 register valueT get
;
3636 register valueT use
;
3637 register valueT mask
;
3639 register valueT unmask
;
3641 /* JF << of >= number of bits in the object is undefined. In
3642 particular SPARC (Sun 4) has problems. */
3643 if (nbytes
>= sizeof (valueT
))
3646 if (nbytes
> sizeof (valueT
))
3649 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3653 /* Don't store these bits. */
3654 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3655 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3658 unmask
= ~mask
; /* Do store these bits. */
3661 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3662 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3665 get
= exp
->X_add_number
;
3667 if ((get
& mask
) != 0
3668 && ((get
& mask
) != mask
3669 || (get
& hibit
) == 0))
3670 { /* Leading bits contain both 0s & 1s. */
3671 as_warn (_("value 0x%lx truncated to 0x%lx"),
3672 (unsigned long) get
, (unsigned long) use
);
3674 /* Put bytes in right order. */
3675 md_number_to_chars (p
, use
, (int) nbytes
);
3677 else if (op
== O_big
)
3680 LITTLENUM_TYPE
*nums
;
3682 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3684 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3687 as_warn (_("bignum truncated to %d bytes"), nbytes
);
3691 if (target_big_endian
)
3693 while (nbytes
> size
)
3695 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3696 nbytes
-= CHARS_PER_LITTLENUM
;
3697 p
+= CHARS_PER_LITTLENUM
;
3700 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3701 while (size
>= CHARS_PER_LITTLENUM
)
3704 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3705 size
-= CHARS_PER_LITTLENUM
;
3706 p
+= CHARS_PER_LITTLENUM
;
3711 nums
= generic_bignum
;
3712 while (size
>= CHARS_PER_LITTLENUM
)
3714 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3716 size
-= CHARS_PER_LITTLENUM
;
3717 p
+= CHARS_PER_LITTLENUM
;
3718 nbytes
-= CHARS_PER_LITTLENUM
;
3721 while (nbytes
>= CHARS_PER_LITTLENUM
)
3723 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3724 nbytes
-= CHARS_PER_LITTLENUM
;
3725 p
+= CHARS_PER_LITTLENUM
;
3731 memset (p
, 0, nbytes
);
3733 /* Now we need to generate a fixS to record the symbol value.
3734 This is easy for BFD. For other targets it can be more
3735 complex. For very complex cases (currently, the HPPA and
3736 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3737 want. For simpler cases, you can define TC_CONS_RELOC to be
3738 the name of the reloc code that should be stored in the fixS.
3739 If neither is defined, the code uses NO_RELOC if it is
3740 defined, and otherwise uses 0. */
3742 #ifdef BFD_ASSEMBLER
3743 #ifdef TC_CONS_FIX_NEW
3744 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3747 bfd_reloc_code_real_type r
;
3764 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3768 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3773 #ifdef TC_CONS_FIX_NEW
3774 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3776 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3777 it is defined, otherwise use NO_RELOC if it is defined,
3779 #ifndef TC_CONS_RELOC
3781 #define TC_CONS_RELOC NO_RELOC
3783 #define TC_CONS_RELOC 0
3786 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3788 #endif /* TC_CONS_FIX_NEW */
3789 #endif /* BFD_ASSEMBLER */
3793 #ifdef BITFIELD_CONS_EXPRESSIONS
3795 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3796 w:x,y:z, where w and y are bitwidths and x and y are values. They
3797 then pack them all together. We do a little better in that we allow
3798 them in words, longs, etc. and we'll pack them in target byte order
3801 The rules are: pack least significat bit first, if a field doesn't
3802 entirely fit, put it in the next unit. Overflowing the bitfield is
3803 explicitly *not* even a warning. The bitwidth should be considered
3806 To use this function the tc-XXX.h file should define
3807 BITFIELD_CONS_EXPRESSIONS. */
3810 parse_bitfield_cons (exp
, nbytes
)
3812 unsigned int nbytes
;
3814 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3815 char *hold
= input_line_pointer
;
3817 (void) expression (exp
);
3819 if (*input_line_pointer
== ':')
3826 unsigned long width
;
3828 if (*input_line_pointer
!= ':')
3830 input_line_pointer
= hold
;
3832 } /* Next piece is not a bitfield. */
3834 /* In the general case, we can't allow
3835 full expressions with symbol
3836 differences and such. The relocation
3837 entries for symbols not defined in this
3838 assembly would require arbitrary field
3839 widths, positions, and masks which most
3840 of our current object formats don't
3843 In the specific case where a symbol
3844 *is* defined in this assembly, we
3845 *could* build fixups and track it, but
3846 this could lead to confusion for the
3847 backends. I'm lazy. I'll take any
3848 SEG_ABSOLUTE. I think that means that
3849 you can use a previous .set or
3850 .equ type symbol. xoxorich. */
3852 if (exp
->X_op
== O_absent
)
3854 as_warn (_("using a bit field width of zero"));
3855 exp
->X_add_number
= 0;
3856 exp
->X_op
= O_constant
;
3857 } /* Implied zero width bitfield. */
3859 if (exp
->X_op
!= O_constant
)
3861 *input_line_pointer
= '\0';
3862 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3863 *input_line_pointer
= ':';
3864 demand_empty_rest_of_line ();
3866 } /* Too complex. */
3868 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3870 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3871 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3872 width
= BITS_PER_CHAR
* nbytes
;
3875 if (width
> bits_available
)
3877 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3878 input_line_pointer
= hold
;
3879 exp
->X_add_number
= value
;
3884 hold
= ++input_line_pointer
;
3886 (void) expression (exp
);
3887 if (exp
->X_op
!= O_constant
)
3889 char cache
= *input_line_pointer
;
3891 *input_line_pointer
= '\0';
3892 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3893 *input_line_pointer
= cache
;
3894 demand_empty_rest_of_line ();
3896 } /* Too complex. */
3898 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3899 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3901 if ((bits_available
-= width
) == 0
3902 || is_it_end_of_statement ()
3903 || *input_line_pointer
!= ',')
3906 } /* All the bitfields we're gonna get. */
3908 hold
= ++input_line_pointer
;
3909 (void) expression (exp
);
3912 exp
->X_add_number
= value
;
3913 exp
->X_op
= O_constant
;
3914 exp
->X_unsigned
= 1;
3918 #endif /* BITFIELD_CONS_EXPRESSIONS */
3920 /* Handle an MRI style string expression. */
3924 parse_mri_cons (exp
, nbytes
)
3926 unsigned int nbytes
;
3928 if (*input_line_pointer
!= '\''
3929 && (input_line_pointer
[1] != '\''
3930 || (*input_line_pointer
!= 'A'
3931 && *input_line_pointer
!= 'E')))
3932 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3936 unsigned int result
= 0;
3938 /* An MRI style string. Cut into as many bytes as will fit into
3939 a nbyte chunk, left justify if necessary, and separate with
3940 commas so we can try again later. */
3941 if (*input_line_pointer
== 'A')
3942 ++input_line_pointer
;
3943 else if (*input_line_pointer
== 'E')
3945 as_bad (_("EBCDIC constants are not supported"));
3946 ++input_line_pointer
;
3949 input_line_pointer
++;
3950 for (scan
= 0; scan
< nbytes
; scan
++)
3952 if (*input_line_pointer
== '\'')
3954 if (input_line_pointer
[1] == '\'')
3956 input_line_pointer
++;
3961 result
= (result
<< 8) | (*input_line_pointer
++);
3965 while (scan
< nbytes
)
3971 /* Create correct expression. */
3972 exp
->X_op
= O_constant
;
3973 exp
->X_add_number
= result
;
3975 /* Fake it so that we can read the next char too. */
3976 if (input_line_pointer
[0] != '\'' ||
3977 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3979 input_line_pointer
-= 2;
3980 input_line_pointer
[0] = ',';
3981 input_line_pointer
[1] = '\'';
3984 input_line_pointer
++;
3987 #endif /* TC_M68K */
3989 #ifdef REPEAT_CONS_EXPRESSIONS
3991 /* Parse a repeat expression for cons. This is used by the MIPS
3992 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3993 object file COUNT times.
3995 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3998 parse_repeat_cons (exp
, nbytes
)
4000 unsigned int nbytes
;
4007 if (*input_line_pointer
!= ':')
4009 /* No repeat count. */
4013 ++input_line_pointer
;
4014 expression (&count
);
4015 if (count
.X_op
!= O_constant
4016 || count
.X_add_number
<= 0)
4018 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4022 /* The cons function is going to output this expression once. So we
4023 output it count - 1 times. */
4024 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
4025 emit_expr (exp
, nbytes
);
4028 #endif /* REPEAT_CONS_EXPRESSIONS */
4030 /* Parse a floating point number represented as a hex constant. This
4031 permits users to specify the exact bits they want in the floating
4035 hex_float (float_type
, bytes
)
4069 as_bad (_("unknown floating type type '%c'"), float_type
);
4073 /* It would be nice if we could go through expression to parse the
4074 hex constant, but if we get a bignum it's a pain to sort it into
4075 the buffer correctly. */
4077 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4081 /* The MRI assembler accepts arbitrary underscores strewn about
4082 through the hex constant, so we ignore them as well. */
4083 if (*input_line_pointer
== '_')
4085 ++input_line_pointer
;
4091 as_warn (_("floating point constant too large"));
4094 d
= hex_value (*input_line_pointer
) << 4;
4095 ++input_line_pointer
;
4096 while (*input_line_pointer
== '_')
4097 ++input_line_pointer
;
4098 if (hex_p (*input_line_pointer
))
4100 d
+= hex_value (*input_line_pointer
);
4101 ++input_line_pointer
;
4103 if (target_big_endian
)
4106 bytes
[length
- i
- 1] = d
;
4112 if (target_big_endian
)
4113 memset (bytes
+ i
, 0, length
- i
);
4115 memset (bytes
, 0, length
- i
);
4123 CONStruct some more frag chars of .floats .ffloats etc.
4124 Makes 0 or more new frags.
4125 If need_pass_2 == 1, no frags are emitted.
4126 This understands only floating literals, not expressions. Sorry.
4128 A floating constant is defined by atof_generic(), except it is preceded
4129 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4130 reading, I decided to be incompatible. This always tries to give you
4131 rounded bits to the precision of the pseudo-op. Former AS did premature
4132 truncatation, restored noisy bits instead of trailing 0s AND gave you
4133 a choice of 2 flavours of noise according to which of 2 floating-point
4134 scanners you directed AS to use.
4136 In: input_line_pointer->whitespace before, or '0' of flonum. */
4139 float_cons (float_type
)
4140 /* Clobbers input_line-pointer, checks end-of-line. */
4141 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4144 int length
; /* Number of chars in an object. */
4145 register char *err
; /* Error from scanning floating literal. */
4146 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4148 if (is_it_end_of_statement ())
4150 demand_empty_rest_of_line ();
4154 #ifdef md_flush_pending_output
4155 md_flush_pending_output ();
4160 /* input_line_pointer->1st char of a flonum (we hope!). */
4163 /* Skip any 0{letter} that may be present. Don't even check if the
4164 letter is legal. Someone may invent a "z" format and this routine
4165 has no use for such information. Lusers beware: you get
4166 diagnostics if your input is ill-conditioned. */
4167 if (input_line_pointer
[0] == '0'
4168 && ISALPHA (input_line_pointer
[1]))
4169 input_line_pointer
+= 2;
4171 /* Accept :xxxx, where the x's are hex digits, for a floating
4172 point with the exact digits specified. */
4173 if (input_line_pointer
[0] == ':')
4175 ++input_line_pointer
;
4176 length
= hex_float (float_type
, temp
);
4179 ignore_rest_of_line ();
4185 err
= md_atof (float_type
, temp
, &length
);
4186 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4190 as_bad (_("bad floating literal: %s"), err
);
4191 ignore_rest_of_line ();
4202 #ifdef REPEAT_CONS_EXPRESSIONS
4203 if (*input_line_pointer
== ':')
4205 expressionS count_exp
;
4207 ++input_line_pointer
;
4208 expression (&count_exp
);
4210 if (count_exp
.X_op
!= O_constant
4211 || count_exp
.X_add_number
<= 0)
4212 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4214 count
= count_exp
.X_add_number
;
4218 while (--count
>= 0)
4220 p
= frag_more (length
);
4221 memcpy (p
, temp
, (unsigned int) length
);
4226 while (*input_line_pointer
++ == ',');
4228 /* Put terminator back into stream. */
4229 --input_line_pointer
;
4230 demand_empty_rest_of_line ();
4233 /* Return the size of a LEB128 value. */
4236 sizeof_sleb128 (value
)
4239 register int size
= 0;
4240 register unsigned byte
;
4244 byte
= (value
& 0x7f);
4245 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4246 Fortunately, we can structure things so that the extra work reduces
4247 to a noop on systems that do things "properly". */
4248 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4251 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4252 || ((value
== -1) && ((byte
& 0x40) != 0))));
4258 sizeof_uleb128 (value
)
4261 register int size
= 0;
4262 register unsigned byte
;
4266 byte
= (value
& 0x7f);
4276 sizeof_leb128 (value
, sign
)
4281 return sizeof_sleb128 ((offsetT
) value
);
4283 return sizeof_uleb128 (value
);
4286 /* Output a LEB128 value. */
4289 output_sleb128 (p
, value
)
4293 register char *orig
= p
;
4298 unsigned byte
= (value
& 0x7f);
4300 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4301 Fortunately, we can structure things so that the extra work reduces
4302 to a noop on systems that do things "properly". */
4303 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4305 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4306 || ((value
== -1) && ((byte
& 0x40) != 0))));
4318 output_uleb128 (p
, value
)
4326 unsigned byte
= (value
& 0x7f);
4329 /* More bytes to follow. */
4340 output_leb128 (p
, value
, sign
)
4346 return output_sleb128 (p
, (offsetT
) value
);
4348 return output_uleb128 (p
, value
);
4351 /* Do the same for bignums. We combine sizeof with output here in that
4352 we don't output for NULL values of P. It isn't really as critical as
4353 for "normal" values that this be streamlined. */
4356 output_big_sleb128 (p
, bignum
, size
)
4358 LITTLENUM_TYPE
*bignum
;
4366 /* Strip leading sign extensions off the bignum. */
4367 while (size
> 0 && bignum
[size
- 1] == (LITTLENUM_TYPE
) -1)
4372 if (loaded
< 7 && size
> 0)
4374 val
|= (*bignum
<< loaded
);
4375 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4386 if ((val
== 0 && (byte
& 0x40) == 0)
4387 || (~(val
| ~(((valueT
) 1 << loaded
) - 1)) == 0
4388 && (byte
& 0x40) != 0))
4396 while (byte
& 0x80);
4402 output_big_uleb128 (p
, bignum
, size
)
4404 LITTLENUM_TYPE
*bignum
;
4412 /* Strip leading zeros off the bignum. */
4413 /* XXX: Is this needed? */
4414 while (size
> 0 && bignum
[size
- 1] == 0)
4419 if (loaded
< 7 && size
> 0)
4421 val
|= (*bignum
<< loaded
);
4422 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4431 if (size
> 0 || val
)
4438 while (byte
& 0x80);
4444 output_big_leb128 (p
, bignum
, size
, sign
)
4446 LITTLENUM_TYPE
*bignum
;
4450 return output_big_sleb128 (p
, bignum
, size
);
4452 return output_big_uleb128 (p
, bignum
, size
);
4455 /* Generate the appropriate fragments for a given expression to emit a
4459 emit_leb128_expr (exp
, sign
)
4463 operatorT op
= exp
->X_op
;
4466 if (op
== O_absent
|| op
== O_illegal
)
4468 as_warn (_("zero assumed for missing expression"));
4469 exp
->X_add_number
= 0;
4472 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4474 as_bad (_("floating point number invalid"));
4475 exp
->X_add_number
= 0;
4478 else if (op
== O_register
)
4480 as_warn (_("register value used as expression"));
4484 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
4485 a signal that this is leb128 data. It shouldn't optimize this away. */
4487 if (check_eh_frame (exp
, &nbytes
))
4490 /* Let the backend know that subsequent data may be byte aligned. */
4491 #ifdef md_cons_align
4495 if (op
== O_constant
)
4497 /* If we've got a constant, emit the thing directly right now. */
4499 valueT value
= exp
->X_add_number
;
4503 size
= sizeof_leb128 (value
, sign
);
4504 p
= frag_more (size
);
4505 output_leb128 (p
, value
, sign
);
4507 else if (op
== O_big
)
4509 /* O_big is a different sort of constant. */
4514 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4515 p
= frag_more (size
);
4516 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4520 /* Otherwise, we have to create a variable sized fragment and
4521 resolve things later. */
4523 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
4524 make_expr_symbol (exp
), 0, (char *) NULL
);
4528 /* Parse the .sleb128 and .uleb128 pseudos. */
4539 emit_leb128_expr (&exp
, sign
);
4541 while (*input_line_pointer
++ == ',');
4543 input_line_pointer
--;
4544 demand_empty_rest_of_line ();
4547 /* We read 0 or more ',' separated, double-quoted strings.
4548 Caller should have checked need_pass_2 is FALSE because we don't
4552 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4553 /* Checks end-of-line. */
4554 register int append_zero
; /* 0: don't append '\0', else 1. */
4556 register unsigned int c
;
4559 #ifdef md_flush_pending_output
4560 md_flush_pending_output ();
4563 /* The following awkward logic is to parse ZERO or more strings,
4564 comma separated. Recall a string expression includes spaces
4565 before the opening '\"' and spaces after the closing '\"'.
4566 We fake a leading ',' if there is (supposed to be)
4567 a 1st, expression. We keep demanding expressions for each ','. */
4568 if (is_it_end_of_statement ())
4570 c
= 0; /* Skip loop. */
4571 ++input_line_pointer
; /* Compensate for end of loop. */
4575 c
= ','; /* Do loop. */
4577 /* If we have been switched into the abs_section then we
4578 will not have an obstack onto which we can hang strings. */
4579 if (now_seg
== absolute_section
)
4581 as_bad (_("strings must be placed into a section"));
4583 ignore_rest_of_line ();
4586 while (c
== ',' || c
== '<' || c
== '"')
4589 switch (*input_line_pointer
)
4592 ++input_line_pointer
; /*->1st char of string. */
4593 start
= input_line_pointer
;
4594 while (is_a_char (c
= next_char_of_string ()))
4596 FRAG_APPEND_1_CHAR (c
);
4600 FRAG_APPEND_1_CHAR (0);
4602 know (input_line_pointer
[-1] == '\"');
4606 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4607 will emit .string with a filename in the .debug section
4608 after a sequence of constants. See the comment in
4609 emit_expr for the sequence. emit_expr will set
4610 dwarf_file_string to non-zero if this string might be a
4611 source file name. */
4612 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4613 dwarf_file_string
= 0;
4614 else if (dwarf_file_string
)
4616 c
= input_line_pointer
[-1];
4617 input_line_pointer
[-1] = '\0';
4618 listing_source_file (start
);
4619 input_line_pointer
[-1] = c
;
4626 input_line_pointer
++;
4627 c
= get_single_number ();
4628 FRAG_APPEND_1_CHAR (c
);
4629 if (*input_line_pointer
!= '>')
4631 as_bad (_("expected <nn>"));
4633 input_line_pointer
++;
4636 input_line_pointer
++;
4640 c
= *input_line_pointer
;
4643 demand_empty_rest_of_line ();
4646 /* FIXME-SOMEDAY: I had trouble here on characters with the
4647 high bits set. We'll probably also have trouble with
4648 multibyte chars, wide chars, etc. Also be careful about
4649 returning values bigger than 1 byte. xoxorich. */
4652 next_char_of_string ()
4654 register unsigned int c
;
4656 c
= *input_line_pointer
++ & CHAR_MASK
;
4664 as_warn (_("unterminated string; newline inserted"));
4665 bump_line_counters ();
4668 #ifndef NO_STRING_ESCAPES
4670 switch (c
= *input_line_pointer
++)
4698 break; /* As itself. */
4714 for (i
= 0, number
= 0;
4715 ISDIGIT (c
) && i
< 3;
4716 c
= *input_line_pointer
++, i
++)
4718 number
= number
* 8 + c
- '0';
4723 --input_line_pointer
;
4732 c
= *input_line_pointer
++;
4733 while (ISXDIGIT (c
))
4736 number
= number
* 16 + c
- '0';
4737 else if (ISUPPER (c
))
4738 number
= number
* 16 + c
- 'A' + 10;
4740 number
= number
* 16 + c
- 'a' + 10;
4741 c
= *input_line_pointer
++;
4744 --input_line_pointer
;
4749 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4750 as_warn (_("unterminated string; newline inserted"));
4752 bump_line_counters ();
4757 #ifdef ONLY_STANDARD_ESCAPES
4758 as_bad (_("bad escaped character in string"));
4760 #endif /* ONLY_STANDARD_ESCAPES */
4765 #endif /* ! defined (NO_STRING_ESCAPES) */
4774 get_segmented_expression (expP
)
4775 register expressionS
*expP
;
4777 register segT retval
;
4779 retval
= expression (expP
);
4780 if (expP
->X_op
== O_illegal
4781 || expP
->X_op
== O_absent
4782 || expP
->X_op
== O_big
)
4784 as_bad (_("expected address expression"));
4785 expP
->X_op
= O_constant
;
4786 expP
->X_add_number
= 0;
4787 retval
= absolute_section
;
4793 get_known_segmented_expression (expP
)
4794 register expressionS
*expP
;
4796 register segT retval
;
4798 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4800 /* There is no easy way to extract the undefined symbol from the
4802 if (expP
->X_add_symbol
!= NULL
4803 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4804 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4805 S_GET_NAME (expP
->X_add_symbol
));
4807 as_warn (_("some symbol undefined; zero assumed"));
4808 retval
= absolute_section
;
4809 expP
->X_op
= O_constant
;
4810 expP
->X_add_number
= 0;
4812 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4817 get_absolute_expr (exp
)
4821 if (exp
->X_op
!= O_constant
)
4823 if (exp
->X_op
!= O_absent
)
4824 as_bad (_("bad or irreducible absolute expression"));
4825 exp
->X_add_number
= 0;
4827 return exp
->X_add_number
;
4831 get_absolute_expression ()
4835 return get_absolute_expr (&exp
);
4838 char /* Return terminator. */
4839 get_absolute_expression_and_terminator (val_pointer
)
4840 long *val_pointer
; /* Return value of expression. */
4842 /* FIXME: val_pointer should probably be offsetT *. */
4843 *val_pointer
= (long) get_absolute_expression ();
4844 return (*input_line_pointer
++);
4847 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4848 Give a warning if that happens. */
4851 demand_copy_C_string (len_pointer
)
4856 if ((s
= demand_copy_string (len_pointer
)) != 0)
4860 for (len
= *len_pointer
; len
> 0; len
--)
4867 as_bad (_("this string may not contain \'\\0\'"));
4875 /* Demand string, but return a safe (=private) copy of the string.
4876 Return NULL if we can't read a string here. */
4879 demand_copy_string (lenP
)
4882 register unsigned int c
;
4888 if (*input_line_pointer
== '\"')
4890 input_line_pointer
++; /* Skip opening quote. */
4892 while (is_a_char (c
= next_char_of_string ()))
4894 obstack_1grow (¬es
, c
);
4897 /* JF this next line is so demand_copy_C_string will return a
4898 null terminated string. */
4899 obstack_1grow (¬es
, '\0');
4900 retval
= obstack_finish (¬es
);
4904 as_warn (_("missing string"));
4906 ignore_rest_of_line ();
4912 /* In: Input_line_pointer->next character.
4914 Do: Skip input_line_pointer over all whitespace.
4916 Out: 1 if input_line_pointer->end-of-line. */
4919 is_it_end_of_statement ()
4922 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4926 equals (sym_name
, reassign
)
4930 register symbolS
*symbolP
; /* Symbol we are working with. */
4934 input_line_pointer
++;
4935 if (*input_line_pointer
== '=')
4936 input_line_pointer
++;
4938 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4939 input_line_pointer
++;
4942 stop
= mri_comment_field (&stopc
);
4944 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4946 /* Turn '. = mumble' into a .org mumble. */
4947 register segT segment
;
4950 segment
= get_known_segmented_expression (&exp
);
4952 do_org (segment
, &exp
, 0);
4959 symbolP
= symbol_find (sym_name
);
4960 local
= symbolP
== NULL
;
4962 #endif /* OBJ_COFF */
4963 symbolP
= symbol_find_or_make (sym_name
);
4964 /* Permit register names to be redefined. */
4966 && S_IS_DEFINED (symbolP
)
4967 && S_GET_SEGMENT (symbolP
) != reg_section
)
4968 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP
));
4971 /* "set" symbols are local unless otherwise specified. */
4973 SF_SET_LOCAL (symbolP
);
4974 #endif /* OBJ_COFF */
4976 pseudo_set (symbolP
);
4981 /* Check garbage after the expression. */
4982 ignore_rest_of_line ();
4983 mri_comment_end (stop
, stopc
);
4987 /* .incbin -- include a file verbatim at the current location. */
4991 int x ATTRIBUTE_UNUSED
;
5002 #ifdef md_flush_pending_output
5003 md_flush_pending_output ();
5007 filename
= demand_copy_string (& len
);
5008 if (filename
== NULL
)
5013 /* Look for optional skip and count. */
5014 if (* input_line_pointer
== ',')
5016 ++ input_line_pointer
;
5017 skip
= get_absolute_expression ();
5021 if (* input_line_pointer
== ',')
5023 ++ input_line_pointer
;
5025 count
= get_absolute_expression ();
5027 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
5033 demand_empty_rest_of_line ();
5035 /* Try opening absolute path first, then try include dirs. */
5036 binfile
= fopen (filename
, FOPEN_RB
);
5037 if (binfile
== NULL
)
5041 path
= xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
5043 for (i
= 0; i
< include_dir_count
; i
++)
5045 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
5047 binfile
= fopen (path
, FOPEN_RB
);
5048 if (binfile
!= NULL
)
5052 if (binfile
== NULL
)
5053 as_bad (_("file not found: %s"), filename
);
5056 path
= xstrdup (filename
);
5062 register_dependency (path
);
5064 /* Compute the length of the file. */
5065 if (fseek (binfile
, 0, SEEK_END
) != 0)
5067 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
5070 file_len
= ftell (binfile
);
5072 /* If a count was not specified use the size of the file. */
5076 if (skip
+ count
> file_len
)
5078 as_bad (_("skip (%ld) + count (%ld) larger than file size (%ld)"),
5079 skip
, count
, file_len
);
5083 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
5085 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
5089 /* Allocate frag space and store file contents in it. */
5090 binfrag
= frag_more (count
);
5092 bytes
= fread (binfrag
, 1, count
, binfile
);
5094 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5095 path
, bytes
, count
);
5098 if (binfile
!= NULL
)
5104 /* .include -- include a file at this point. */
5108 int arg ATTRIBUTE_UNUSED
;
5117 filename
= demand_copy_string (&i
);
5118 if (filename
== NULL
)
5120 /* demand_copy_string has already printed an error and
5121 called ignore_rest_of_line. */
5129 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5130 && *input_line_pointer
!= ' '
5131 && *input_line_pointer
!= '\t')
5133 obstack_1grow (¬es
, *input_line_pointer
);
5134 ++input_line_pointer
;
5138 obstack_1grow (¬es
, '\0');
5139 filename
= obstack_finish (¬es
);
5140 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5141 ++input_line_pointer
;
5144 demand_empty_rest_of_line ();
5145 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
5147 for (i
= 0; i
< include_dir_count
; i
++)
5149 strcpy (path
, include_dirs
[i
]);
5151 strcat (path
, filename
);
5152 if (0 != (try = fopen (path
, FOPEN_RT
)))
5162 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5163 register_dependency (path
);
5164 input_scrub_insert_file (path
);
5168 add_include_dir (path
)
5173 if (include_dir_count
== 0)
5175 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5176 include_dirs
[0] = "."; /* Current dir. */
5177 include_dir_count
= 2;
5181 include_dir_count
++;
5183 (char **) realloc (include_dirs
,
5184 include_dir_count
* sizeof (*include_dirs
));
5187 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5190 if (i
> include_dir_maxlen
)
5191 include_dir_maxlen
= i
;
5194 /* Output debugging information to denote the source file. */
5197 generate_file_debug ()
5199 if (debug_type
== DEBUG_STABS
)
5200 stabs_generate_asm_file ();
5203 /* Output line number debugging information for the current source line. */
5206 generate_lineno_debug ()
5210 case DEBUG_UNSPECIFIED
:
5215 stabs_generate_asm_lineno ();
5218 ecoff_generate_asm_lineno ();
5221 /* ??? We could here indicate to dwarf2dbg.c that something
5222 has changed. However, since there is additional backend
5223 support that is required (calling dwarf2_emit_insn), we
5224 let dwarf2dbg.c call as_where on its own. */
5229 /* Output debugging information to mark a function entry point or end point.
5230 END_P is zero for .func, and non-zero for .endfunc. */
5236 do_s_func (end_p
, NULL
);
5239 /* Subroutine of s_func so targets can choose a different default prefix.
5240 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5243 do_s_func (end_p
, default_prefix
)
5245 const char *default_prefix
;
5247 /* Record the current function so that we can issue an error message for
5248 misplaced .func,.endfunc, and also so that .endfunc needs no
5250 static char *current_name
;
5251 static char *current_label
;
5255 if (current_name
== NULL
)
5257 as_bad (_("missing .func"));
5258 ignore_rest_of_line ();
5262 if (debug_type
== DEBUG_STABS
)
5263 stabs_generate_asm_endfunc (current_name
, current_label
);
5265 current_name
= current_label
= NULL
;
5270 char delim1
, delim2
;
5272 if (current_name
!= NULL
)
5274 as_bad (_(".endfunc missing for previous .func"));
5275 ignore_rest_of_line ();
5279 name
= input_line_pointer
;
5280 delim1
= get_symbol_end ();
5281 name
= xstrdup (name
);
5282 *input_line_pointer
= delim1
;
5284 if (*input_line_pointer
!= ',')
5287 asprintf (&label
, "%s%s", default_prefix
, name
);
5290 char leading_char
= 0;
5291 #ifdef BFD_ASSEMBLER
5292 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5294 /* Missing entry point, use function's name with the leading
5297 asprintf (&label
, "%c%s", leading_char
, name
);
5304 ++input_line_pointer
;
5306 label
= input_line_pointer
;
5307 delim2
= get_symbol_end ();
5308 label
= xstrdup (label
);
5309 *input_line_pointer
= delim2
;
5312 if (debug_type
== DEBUG_STABS
)
5313 stabs_generate_asm_func (name
, label
);
5315 current_name
= name
;
5316 current_label
= label
;
5319 demand_empty_rest_of_line ();
5324 int arg ATTRIBUTE_UNUSED
;
5326 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5328 ++input_line_pointer
;
5330 ++input_line_pointer
;
5334 read_print_statistics (file
)
5337 hash_print_statistics (file
, "pseudo-op table", po_hash
);
5340 /* Inserts the given line into the input stream.
5342 This call avoids macro/conditionals nesting checking, since the contents of
5343 the line are assumed to replace the contents of a line already scanned.
5345 An appropriate use of this function would be substition of input lines when
5346 called by md_start_line_hook(). The given line is assumed to already be
5347 properly scrubbed. */
5350 input_scrub_insert_line (line
)
5355 sb_add_string (&newline
, line
);
5356 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
5358 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
5361 /* Insert a file into the input stream; the path must resolve to an actual
5362 file; no include path searching or dependency registering is performed. */
5365 input_scrub_insert_file (path
)
5368 input_scrub_include_file (path
, input_line_pointer
);
5369 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);