read.c 144 KB
Newer Older
Richard Henderson's avatar
Richard Henderson committed
1
/* read.c - read a source file -
Nick Clifton's avatar
Nick Clifton committed
2
   Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
Nick Clifton's avatar
Nick Clifton committed
3
   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
Roland McGrath's avatar
gas/  
Roland McGrath committed
4
   2010, 2011, 2012  Free Software Foundation, Inc.
Richard Henderson's avatar
Richard Henderson committed
5

Nick Clifton's avatar
Nick Clifton committed
6
   This file is part of GAS, the GNU Assembler.
Richard Henderson's avatar
Richard Henderson committed
7

Nick Clifton's avatar
Nick Clifton committed
8 9 10 11
   GAS is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.
Richard Henderson's avatar
Richard Henderson committed
12

Nick Clifton's avatar
Nick Clifton committed
13 14 15 16
   GAS is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
Richard Henderson's avatar
Richard Henderson committed
17

Nick Clifton's avatar
Nick Clifton committed
18 19 20 21
   You should have received a copy of the GNU General Public License
   along with GAS; see the file COPYING.  If not, write to the Free
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
   02110-1301, USA.  */
Richard Henderson's avatar
Richard Henderson committed
22

23
/* If your chars aren't 8 bits, you will change this a bit (eg. to 0xFF).
Nick Clifton's avatar
Nick Clifton committed
24 25 26
   But then, GNU isn't spozed to run on your machine anyway.
   (RMS is so shortsighted sometimes.)  */
#define MASK_CHAR ((int)(unsigned char) -1)
Richard Henderson's avatar
Richard Henderson committed
27 28

/* This is the largest known floating point format (for now). It will
Nick Clifton's avatar
Nick Clifton committed
29
   grow when we do 4361 style flonums.  */
Richard Henderson's avatar
Richard Henderson committed
30 31
#define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)

Kazu Hirata's avatar
Kazu Hirata committed
32
/* Routines that read assembler source text to build spaghetti in memory.
Richard Henderson's avatar
Richard Henderson committed
33 34 35
   Another group of these functions is in the expr.c module.  */

#include "as.h"
36
#include "safe-ctype.h"
Richard Henderson's avatar
Richard Henderson committed
37 38 39 40 41
#include "subsegs.h"
#include "sb.h"
#include "macro.h"
#include "obstack.h"
#include "ecoff.h"
42
#include "dw2gencfi.h"
43
#include "wchar.h"
Richard Henderson's avatar
Richard Henderson committed
44 45

#ifndef TC_START_LABEL
46
#define TC_START_LABEL(x,y,z) (x == ':')
Richard Henderson's avatar
Richard Henderson committed
47 48
#endif

49 50
/* Set by the object-format or the target.  */
#ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
51
#define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR)		\
Nick Clifton's avatar
Nick Clifton committed
52
  do								\
53 54 55 56 57 58 59 60 61
    {								\
      if ((SIZE) >= 8)						\
	(P2VAR) = 3;						\
      else if ((SIZE) >= 4)					\
	(P2VAR) = 2;						\
      else if ((SIZE) >= 2)					\
	(P2VAR) = 1;						\
      else							\
	(P2VAR) = 0;						\
Nick Clifton's avatar
Nick Clifton committed
62 63
    }								\
  while (0)
64 65
#endif

Nick Clifton's avatar
Nick Clifton committed
66
char *input_line_pointer;	/*->next char of source file to parse.  */
Richard Henderson's avatar
Richard Henderson committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92

#if BITS_PER_CHAR != 8
/*  The following table is indexed by[(char)] and will break if
    a char does not have exactly 256 states (hopefully 0:255!)!  */
die horribly;
#endif

#ifndef LEX_AT
#define LEX_AT 0
#endif

#ifndef LEX_BR
/* The RS/6000 assembler uses {,},[,] as parts of symbol names.  */
#define LEX_BR 0
#endif

#ifndef LEX_PCT
/* The Delta 68k assembler permits % inside label names.  */
#define LEX_PCT 0
#endif

#ifndef LEX_QM
/* The PowerPC Windows NT assemblers permits ? inside label names.  */
#define LEX_QM 0
#endif

93
#ifndef LEX_HASH
Jim Wilson's avatar
Jim Wilson committed
94 95
/* The IA-64 assembler uses # as a suffix designating a symbol.  We include
   it in the symbol and strip it out in tc_canonicalize_symbol_name.  */
96 97 98
#define LEX_HASH 0
#endif

Richard Henderson's avatar
Richard Henderson committed
99 100 101 102 103 104 105 106 107
#ifndef LEX_DOLLAR
#define LEX_DOLLAR 3
#endif

#ifndef LEX_TILDE
/* The Delta 68k assembler permits ~ at start of label names.  */
#define LEX_TILDE 0
#endif

Nick Clifton's avatar
Nick Clifton committed
108
/* Used by is_... macros. our ctype[].  */
109
char lex_type[256] = {
Richard Henderson's avatar
Richard Henderson committed
110 111
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* @ABCDEFGHIJKLMNO */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* PQRSTUVWXYZ[\]^_ */
112
  0, 0, 0, LEX_HASH, LEX_DOLLAR, LEX_PCT, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
Richard Henderson's avatar
Richard Henderson committed
113 114 115 116
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM,	/* 0123456789:;<=>? */
  LEX_AT, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,	/* @ABCDEFGHIJKLMNO */
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, 0, 3, /* PQRSTUVWXYZ[\]^_ */
  0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,	/* `abcdefghijklmno */
Nick Clifton's avatar
Nick Clifton committed
117
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, LEX_TILDE, 0, /* pqrstuvwxyz{|}~.  */
Richard Henderson's avatar
Richard Henderson committed
118 119 120 121 122 123 124 125 126 127
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
};

Nick Clifton's avatar
Nick Clifton committed
128
/* In: a character.
129 130
   Out: 1 if this character ends a line.
	2 if this character is a line separator.  */
131
char is_end_of_line[256] = {
Richard Henderson's avatar
Richard Henderson committed
132
#ifdef CR_EOL
Alan Modra's avatar
Alan Modra committed
133
  1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,	/* @abcdefghijklmno */
Richard Henderson's avatar
Richard Henderson committed
134
#else
Alan Modra's avatar
Alan Modra committed
135
  1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,	/* @abcdefghijklmno */
Richard Henderson's avatar
Richard Henderson committed
136
#endif
Alan Modra's avatar
Alan Modra committed
137 138
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* _!"#$%&'()*+,-./ */
139
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* 0123456789:;<=>? */
Alan Modra's avatar
Alan Modra committed
140 141 142 143 144 145 146 147 148
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
149 150 151
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* */
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0	/* */
Richard Henderson's avatar
Richard Henderson committed
152 153
};

154
#ifndef TC_CASE_SENSITIVE
155 156 157
char original_case_string[128];
#endif

Nick Clifton's avatar
Nick Clifton committed
158
/* Functions private to this file.  */
Richard Henderson's avatar
Richard Henderson committed
159

Nick Clifton's avatar
Nick Clifton committed
160 161
static char *buffer;	/* 1st char of each buffer of lines is here.  */
static char *buffer_limit;	/*->1 + last char in buffer.  */
Richard Henderson's avatar
Richard Henderson committed
162

Nick Clifton's avatar
Nick Clifton committed
163 164 165
/* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
   in the tc-<CPU>.h file.  See the "Porting GAS" section of the
   internals manual.  */
Richard Henderson's avatar
Richard Henderson committed
166 167
int target_big_endian = TARGET_BYTES_BIG_ENDIAN;

Nick Clifton's avatar
Nick Clifton committed
168
/* Variables for handling include file directory table.  */
Richard Henderson's avatar
Richard Henderson committed
169

Nick Clifton's avatar
Nick Clifton committed
170 171 172 173 174 175 176 177
/* Table of pointers to directories to search for .include's.  */
char **include_dirs;

/* How many are in the table.  */
int include_dir_count;

/* Length of longest in table.  */
int include_dir_maxlen = 1;
Richard Henderson's avatar
Richard Henderson committed
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212

#ifndef WORKING_DOT_WORD
struct broken_word *broken_words;
int new_broken_words;
#endif

/* The current offset into the absolute section.  We don't try to
   build frags in the absolute section, since no data can be stored
   there.  We just keep track of the current offset.  */
addressT abs_section_offset;

/* If this line had an MRI style label, it is stored in this variable.
   This is used by some of the MRI pseudo-ops.  */
symbolS *line_label;

/* This global variable is used to support MRI common sections.  We
   translate such sections into a common symbol.  This variable is
   non-NULL when we are in an MRI common section.  */
symbolS *mri_common_symbol;

/* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
   need to align to an even byte boundary unless the next pseudo-op is
   dc.b, ds.b, or dcb.b.  This variable is set to 1 if an alignment
   may be needed.  */
static int mri_pending_align;

#ifndef NO_LISTING
#ifdef OBJ_ELF
/* This variable is set to be non-zero if the next string we see might
   be the name of the source file in DWARF debugging information.  See
   the comment in emit_expr for the format we look for.  */
static int dwarf_file_string;
#endif
#endif

Roland McGrath's avatar
gas/  
Roland McGrath committed
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
/* If the target defines the md_frag_max_var hook then we know
   enough to implement the .bundle_align_mode features.  */
#ifdef md_frag_max_var
# define HANDLE_BUNDLE
#endif

#ifdef HANDLE_BUNDLE
/* .bundle_align_mode sets this.  Normally it's zero.  When nonzero,
   it's the exponent of the bundle size, and aligned instruction bundle
   mode is in effect.  */
static unsigned int bundle_align_p2;

/* These are set by .bundle_lock and .bundle_unlock.  .bundle_lock sets
   bundle_lock_frag to frag_now and then starts a new frag with
   frag_align_code.  At the same time, bundle_lock_frain gets frchain_now,
   so that .bundle_unlock can verify that we didn't change segments.
   .bundle_unlock resets both to NULL.  If we detect a bundling violation,
   then we reset bundle_lock_frchain to NULL as an indicator that we've
   already diagnosed the error with as_bad and don't need a cascade of
   redundant errors, but bundle_lock_frag remains set to indicate that
   we are expecting to see .bundle_unlock.  */
static fragS *bundle_lock_frag;
static frchainS *bundle_lock_frchain;
Roland McGrath's avatar
gas/  
Roland McGrath committed
236 237 238 239

/* This is incremented by .bundle_lock and decremented by .bundle_unlock,
   to allow nesting.  */
static unsigned int bundle_lock_depth;
Roland McGrath's avatar
gas/  
Roland McGrath committed
240 241
#endif

242
static void do_s_func (int end_p, const char *default_prefix);
Kazu Hirata's avatar
Kazu Hirata committed
243 244
static void do_align (int, char *, int, int);
static void s_align (int, int);
245
static void s_altmacro (int);
Jan Beulich's avatar
gas/  
Jan Beulich committed
246
static void s_bad_end (int);
247
static void s_reloc (int);
Kazu Hirata's avatar
Kazu Hirata committed
248 249 250
static int hex_float (int, char *);
static segT get_known_segmented_expression (expressionS * expP);
static void pobegin (void);
Alan Modra's avatar
Alan Modra committed
251
static size_t get_non_macro_line_sb (sb *);
Kazu Hirata's avatar
Kazu Hirata committed
252
static void generate_file_debug (void);
Nick Clifton's avatar
Nick Clifton committed
253
static char *_find_end_of_line (char *, int, int, int);
Richard Henderson's avatar
Richard Henderson committed
254 255

void
Kazu Hirata's avatar
Kazu Hirata committed
256
read_begin (void)
Richard Henderson's avatar
Richard Henderson committed
257 258 259 260 261 262 263 264 265 266 267
{
  const char *p;

  pobegin ();
  obj_read_begin_hook ();

  /* Something close -- but not too close -- to a multiple of 1024.
     The debugging malloc I'm using has 24 bytes of overhead.  */
  obstack_begin (&notes, chunksize);
  obstack_begin (&cond_obstack, chunksize);

Nick Clifton's avatar
Nick Clifton committed
268
  /* Use machine dependent syntax.  */
Richard Henderson's avatar
Richard Henderson committed
269
  for (p = line_separator_chars; *p; p++)
270
    is_end_of_line[(unsigned char) *p] = 2;
Nick Clifton's avatar
Nick Clifton committed
271
  /* Use more.  FIXME-SOMEDAY.  */
Richard Henderson's avatar
Richard Henderson committed
272 273 274 275 276

  if (flag_mri)
    lex_type['?'] = 3;
}

Alan Modra's avatar
gas/  
Alan Modra committed
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
#ifndef TC_ADDRESS_BYTES
#define TC_ADDRESS_BYTES address_bytes

static inline int
address_bytes (void)
{
  /* Choose smallest of 1, 2, 4, 8 bytes that is large enough to
     contain an address.  */
  int n = (stdoutput->arch_info->bits_per_address - 1) / 8;
  n |= n >> 1;
  n |= n >> 2;
  n += 1;
  return n;
}
#endif

Nick Clifton's avatar
Nick Clifton committed
293
/* Set up pseudo-op tables.  */
Richard Henderson's avatar
Richard Henderson committed
294 295 296

static struct hash_control *po_hash;

297
static const pseudo_typeS potable[] = {
Richard Henderson's avatar
Richard Henderson committed
298 299
  {"abort", s_abort, 0},
  {"align", s_align_ptwo, 0},
300
  {"altmacro", s_altmacro, 1},
301 302
  {"ascii", stringer, 8+0},
  {"asciz", stringer, 8+1},
Richard Henderson's avatar
Richard Henderson committed
303 304 305
  {"balign", s_align_bytes, 0},
  {"balignw", s_align_bytes, -2},
  {"balignl", s_align_bytes, -4},
Nick Clifton's avatar
Nick Clifton committed
306
/* block  */
Roland McGrath's avatar
gas/  
Roland McGrath committed
307 308 309 310 311
#ifdef HANDLE_BUNDLE
  {"bundle_align_mode", s_bundle_align_mode, 0},
  {"bundle_lock", s_bundle_lock, 0},
  {"bundle_unlock", s_bundle_unlock, 0},
#endif
Richard Henderson's avatar
Richard Henderson committed
312 313 314 315 316 317
  {"byte", cons, 1},
  {"comm", s_comm, 0},
  {"common", s_mri_common, 0},
  {"common.s", s_mri_common, 1},
  {"data", s_data, 0},
  {"dc", cons, 2},
Alan Modra's avatar
gas/  
Alan Modra committed
318 319 320
#ifdef TC_ADDRESS_BYTES
  {"dc.a", cons, 0},
#endif
Richard Henderson's avatar
Richard Henderson committed
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
  {"dc.b", cons, 1},
  {"dc.d", float_cons, 'd'},
  {"dc.l", cons, 4},
  {"dc.s", float_cons, 'f'},
  {"dc.w", cons, 2},
  {"dc.x", float_cons, 'x'},
  {"dcb", s_space, 2},
  {"dcb.b", s_space, 1},
  {"dcb.d", s_float_space, 'd'},
  {"dcb.l", s_space, 4},
  {"dcb.s", s_float_space, 'f'},
  {"dcb.w", s_space, 2},
  {"dcb.x", s_float_space, 'x'},
  {"ds", s_space, 2},
  {"ds.b", s_space, 1},
  {"ds.d", s_space, 8},
  {"ds.l", s_space, 4},
  {"ds.p", s_space, 12},
  {"ds.s", s_space, 4},
  {"ds.w", s_space, 2},
  {"ds.x", s_space, 12},
  {"debug", s_ignore, 0},
#ifdef S_SET_DESC
  {"desc", s_desc, 0},
#endif
Nick Clifton's avatar
Nick Clifton committed
346
/* dim  */
Richard Henderson's avatar
Richard Henderson committed
347
  {"double", float_cons, 'd'},
Nick Clifton's avatar
Nick Clifton committed
348 349
/* dsect  */
  {"eject", listing_eject, 0},	/* Formfeed listing.  */
Richard Henderson's avatar
Richard Henderson committed
350 351
  {"else", s_else, 0},
  {"elsec", s_else, 0},
352
  {"elseif", s_elseif, (int) O_ne},
Richard Henderson's avatar
Richard Henderson committed
353 354 355 356
  {"end", s_end, 0},
  {"endc", s_endif, 0},
  {"endfunc", s_func, 1},
  {"endif", s_endif, 0},
Jan Beulich's avatar
gas/  
Jan Beulich committed
357 358
  {"endm", s_bad_end, 0},
  {"endr", s_bad_end, 1},
Nick Clifton's avatar
Nick Clifton committed
359
/* endef  */
Richard Henderson's avatar
Richard Henderson committed
360 361
  {"equ", s_set, 0},
  {"equiv", s_set, 1},
362
  {"eqv", s_set, -1},
Richard Henderson's avatar
Richard Henderson committed
363
  {"err", s_err, 0},
364
  {"error", s_errwarn, 1},
Richard Henderson's avatar
Richard Henderson committed
365
  {"exitm", s_mexit, 0},
Nick Clifton's avatar
Nick Clifton committed
366 367
/* extend  */
  {"extern", s_ignore, 0},	/* We treat all undef as ext.  */
Richard Henderson's avatar
Richard Henderson committed
368
  {"appfile", s_app_file, 1},
369
  {"appline", s_app_line, 1},
Richard Henderson's avatar
Richard Henderson committed
370 371 372 373 374 375 376 377 378 379
  {"fail", s_fail, 0},
  {"file", s_app_file, 0},
  {"fill", s_fill, 0},
  {"float", float_cons, 'f'},
  {"format", s_ignore, 0},
  {"func", s_func, 0},
  {"global", s_globl, 0},
  {"globl", s_globl, 0},
  {"hword", cons, 2},
  {"if", s_if, (int) O_ne},
Jan Beulich's avatar
gas/  
Jan Beulich committed
380
  {"ifb", s_ifb, 1},
Richard Henderson's avatar
Richard Henderson committed
381 382 383 384 385 386 387 388
  {"ifc", s_ifc, 0},
  {"ifdef", s_ifdef, 0},
  {"ifeq", s_if, (int) O_eq},
  {"ifeqs", s_ifeqs, 0},
  {"ifge", s_if, (int) O_ge},
  {"ifgt", s_if, (int) O_gt},
  {"ifle", s_if, (int) O_le},
  {"iflt", s_if, (int) O_lt},
Jan Beulich's avatar
gas/  
Jan Beulich committed
389
  {"ifnb", s_ifb, 0},
Richard Henderson's avatar
Richard Henderson committed
390 391 392 393 394
  {"ifnc", s_ifc, 1},
  {"ifndef", s_ifdef, 1},
  {"ifne", s_if, (int) O_ne},
  {"ifnes", s_ifeqs, 1},
  {"ifnotdef", s_ifdef, 1},
Nick Clifton's avatar
Nick Clifton committed
395
  {"incbin", s_incbin, 0},
Richard Henderson's avatar
Richard Henderson committed
396 397 398 399 400 401 402
  {"include", s_include, 0},
  {"int", cons, 4},
  {"irp", s_irp, 0},
  {"irep", s_irp, 0},
  {"irpc", s_irp, 1},
  {"irepc", s_irp, 1},
  {"lcomm", s_lcomm, 0},
Alan Modra's avatar
Alan Modra committed
403
  {"lflags", s_ignore, 0},	/* Listing flags.  */
404
  {"linefile", s_app_line, 0},
Richard Henderson's avatar
Richard Henderson committed
405
  {"linkonce", s_linkonce, 0},
Nick Clifton's avatar
Nick Clifton committed
406
  {"list", listing_list, 1},	/* Turn listing on.  */
Richard Henderson's avatar
Richard Henderson committed
407 408 409 410 411 412 413 414
  {"llen", listing_psize, 1},
  {"long", cons, 4},
  {"lsym", s_lsym, 0},
  {"macro", s_macro, 0},
  {"mexit", s_mexit, 0},
  {"mri", s_mri, 0},
  {".mri", s_mri, 0},	/* Special case so .mri works in MRI mode.  */
  {"name", s_ignore, 0},
415
  {"noaltmacro", s_altmacro, 0},
Richard Henderson's avatar
Richard Henderson committed
416
  {"noformat", s_ignore, 0},
Nick Clifton's avatar
Nick Clifton committed
417
  {"nolist", listing_list, 0},	/* Turn listing off.  */
Richard Henderson's avatar
Richard Henderson committed
418 419 420 421 422 423 424 425 426 427
  {"nopage", listing_nopage, 0},
  {"octa", cons, 16},
  {"offset", s_struct, 0},
  {"org", s_org, 0},
  {"p2align", s_align_ptwo, 0},
  {"p2alignw", s_align_ptwo, -2},
  {"p2alignl", s_align_ptwo, -4},
  {"page", listing_eject, 0},
  {"plen", listing_psize, 0},
  {"print", s_print, 0},
Nick Clifton's avatar
Nick Clifton committed
428
  {"psize", listing_psize, 0},	/* Set paper size.  */
Richard Henderson's avatar
Richard Henderson committed
429 430
  {"purgem", s_purgem, 0},
  {"quad", cons, 8},
431
  {"reloc", s_reloc, 0},
Richard Henderson's avatar
Richard Henderson committed
432 433 434
  {"rep", s_rept, 0},
  {"rept", s_rept, 0},
  {"rva", s_rva, 4},
Nick Clifton's avatar
Nick Clifton committed
435 436 437
  {"sbttl", listing_title, 1},	/* Subtitle of listing.  */
/* scl  */
/* sect  */
Richard Henderson's avatar
Richard Henderson committed
438 439 440
  {"set", s_set, 0},
  {"short", cons, 2},
  {"single", float_cons, 'f'},
Nick Clifton's avatar
Nick Clifton committed
441
/* size  */
Richard Henderson's avatar
Richard Henderson committed
442 443 444 445 446 447 448
  {"space", s_space, 0},
  {"skip", s_space, 0},
  {"sleb128", s_leb128, 1},
  {"spc", s_ignore, 0},
  {"stabd", s_stab, 'd'},
  {"stabn", s_stab, 'n'},
  {"stabs", s_stab, 's'},
449 450 451 452 453
  {"string", stringer, 8+1},
  {"string8", stringer, 8+1},
  {"string16", stringer, 16+1},
  {"string32", stringer, 32+1},
  {"string64", stringer, 64+1},
Richard Henderson's avatar
Richard Henderson committed
454
  {"struct", s_struct, 0},
Nick Clifton's avatar
Nick Clifton committed
455
/* tag  */
Richard Henderson's avatar
Richard Henderson committed
456 457 458 459 460 461 462 463 464 465 466 467
  {"text", s_text, 0},

  /* This is for gcc to use.  It's only just been added (2/94), so gcc
     won't be able to use it for a while -- probably a year or more.
     But once this has been released, check with gcc maintainers
     before deleting it or even changing the spelling.  */
  {"this_GCC_requires_the_GNU_assembler", s_ignore, 0},
  /* If we're folding case -- done for some targets, not necessarily
     all -- the above string in an input file will be converted to
     this one.  Match it either way...  */
  {"this_gcc_requires_the_gnu_assembler", s_ignore, 0},

Nick Clifton's avatar
Nick Clifton committed
468
  {"title", listing_title, 0},	/* Listing title.  */
Richard Henderson's avatar
Richard Henderson committed
469
  {"ttl", listing_title, 0},
Nick Clifton's avatar
Nick Clifton committed
470
/* type  */
Richard Henderson's avatar
Richard Henderson committed
471
  {"uleb128", s_leb128, 0},
Nick Clifton's avatar
Nick Clifton committed
472 473
/* use  */
/* val  */
Richard Henderson's avatar
Richard Henderson committed
474 475 476 477
  {"xcom", s_comm, 0},
  {"xdef", s_globl, 0},
  {"xref", s_ignore, 0},
  {"xstabs", s_xstab, 's'},
478
  {"warning", s_errwarn, 0},
Alexandre Oliva's avatar
Alexandre Oliva committed
479
  {"weakref", s_weakref, 0},
Richard Henderson's avatar
Richard Henderson committed
480 481
  {"word", cons, 2},
  {"zero", s_space, 0},
Nick Clifton's avatar
Nick Clifton committed
482
  {NULL, NULL, 0}			/* End sentinel.  */
Richard Henderson's avatar
Richard Henderson committed
483 484
};

485 486 487
static offsetT
get_absolute_expr (expressionS *exp)
{
488
  expression_and_evaluate (exp);
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
  if (exp->X_op != O_constant)
    {
      if (exp->X_op != O_absent)
	as_bad (_("bad or irreducible absolute expression"));
      exp->X_add_number = 0;
    }
  return exp->X_add_number;
}

offsetT
get_absolute_expression (void)
{
  expressionS exp;

  return get_absolute_expr (&exp);
}

Richard Henderson's avatar
Richard Henderson committed
506 507 508 509
static int pop_override_ok = 0;
static const char *pop_table_name;

void
Kazu Hirata's avatar
Kazu Hirata committed
510
pop_insert (const pseudo_typeS *table)
Richard Henderson's avatar
Richard Henderson committed
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
{
  const char *errtxt;
  const pseudo_typeS *pop;
  for (pop = table; pop->poc_name; pop++)
    {
      errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop);
      if (errtxt && (!pop_override_ok || strcmp (errtxt, "exists")))
	as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name,
		  errtxt);
    }
}

#ifndef md_pop_insert
#define md_pop_insert()		pop_insert(md_pseudo_table)
#endif

#ifndef obj_pop_insert
#define obj_pop_insert()	pop_insert(obj_pseudo_table)
#endif

531 532 533 534
#ifndef cfi_pop_insert
#define cfi_pop_insert()	pop_insert(cfi_pseudo_table)
#endif

Nick Clifton's avatar
Nick Clifton committed
535
static void
Kazu Hirata's avatar
Kazu Hirata committed
536
pobegin (void)
Richard Henderson's avatar
Richard Henderson committed
537 538 539
{
  po_hash = hash_new ();

Nick Clifton's avatar
Nick Clifton committed
540
  /* Do the target-specific pseudo ops.  */
Richard Henderson's avatar
Richard Henderson committed
541 542 543
  pop_table_name = "md";
  md_pop_insert ();

Nick Clifton's avatar
Nick Clifton committed
544
  /* Now object specific.  Skip any that were in the target table.  */
Richard Henderson's avatar
Richard Henderson committed
545 546 547 548
  pop_table_name = "obj";
  pop_override_ok = 1;
  obj_pop_insert ();

Nick Clifton's avatar
Nick Clifton committed
549
  /* Now portable ones.  Skip any that we've seen already.  */
Richard Henderson's avatar
Richard Henderson committed
550 551
  pop_table_name = "standard";
  pop_insert (potable);
552

553
  /* Now CFI ones.  */
554 555 556
  pop_table_name = "cfi";
  pop_override_ok = 1;
  cfi_pop_insert ();
Richard Henderson's avatar
Richard Henderson committed
557 558 559 560 561
}

#define HANDLE_CONDITIONAL_ASSEMBLY()					\
  if (ignore_input ())							\
    {									\
Nick Clifton's avatar
Nick Clifton committed
562
      char *eol = find_end_of_line (input_line_pointer, flag_m68k_mri); \
Jan Beulich's avatar
gas/  
Jan Beulich committed
563 564 565 566
      input_line_pointer = (input_line_pointer <= buffer_limit		\
			    && eol >= buffer_limit)			\
			   ? buffer_limit				\
			   : eol + 1;					\
Richard Henderson's avatar
Richard Henderson committed
567 568 569 570 571 572 573 574 575
      continue;								\
    }

/* This function is used when scrubbing the characters between #APP
   and #NO_APP.  */

static char *scrub_string;
static char *scrub_string_end;

Alan Modra's avatar
Alan Modra committed
576 577
static size_t
scrub_from_string (char *buf, size_t buflen)
Richard Henderson's avatar
Richard Henderson committed
578
{
Alan Modra's avatar
Alan Modra committed
579
  size_t copy;
580 581 582 583 584 585 586

  copy = scrub_string_end - scrub_string;
  if (copy > buflen)
    copy = buflen;
  memcpy (buf, scrub_string, copy);
  scrub_string += copy;
  return copy;
Richard Henderson's avatar
Richard Henderson committed
587 588
}

Jan Beulich's avatar
gas/  
Jan Beulich committed
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614
/* Helper function of read_a_source_file, which tries to expand a macro.  */
static int
try_macro (char term, const char *line)
{
  sb out;
  const char *err;
  macro_entry *macro;

  if (check_macro (line, &out, &err, &macro))
    {
      if (err != NULL)
	as_bad ("%s", err);
      *input_line_pointer++ = term;
      input_scrub_include_sb (&out,
			      input_line_pointer, 1);
      sb_kill (&out);
      buffer_limit =
	input_scrub_next_buffer (&input_line_pointer);
#ifdef md_macro_info
      md_macro_info (macro);
#endif
      return 1;
    }
  return 0;
}

Roland McGrath's avatar
gas/  
Roland McGrath committed
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693
#ifdef HANDLE_BUNDLE
/* Start a new instruction bundle.  Returns the rs_align_code frag that
   will be used to align the new bundle.  */
static fragS *
start_bundle (void)
{
  fragS *frag = frag_now;

  frag_align_code (0, 0);

  while (frag->fr_type != rs_align_code)
    frag = frag->fr_next;

  gas_assert (frag != frag_now);

  return frag;
}

/* Calculate the maximum size after relaxation of the region starting
   at the given frag and extending through frag_now (which is unfinished).  */
static unsigned int
pending_bundle_size (fragS *frag)
{
  unsigned int offset = frag->fr_fix;
  unsigned int size = 0;

  gas_assert (frag != frag_now);
  gas_assert (frag->fr_type == rs_align_code);

  while (frag != frag_now)
    {
      /* This should only happen in what will later become an error case.  */
      if (frag == NULL)
	return 0;

      size += frag->fr_fix;
      if (frag->fr_type == rs_machine_dependent)
	size += md_frag_max_var (frag);

      frag = frag->fr_next;
    }

  gas_assert (frag == frag_now);
  size += frag_now_fix ();
  if (frag->fr_type == rs_machine_dependent)
    size += md_frag_max_var (frag);

  gas_assert (size >= offset);

  return size - offset;
}

/* Finish off the frag created to ensure bundle alignment.  */
static void
finish_bundle (fragS *frag, unsigned int size)
{
  gas_assert (bundle_align_p2 > 0);
  gas_assert (frag->fr_type == rs_align_code);

  if (size > 1)
    {
      /* If there is more than a single byte, then we need to set up the
	 alignment frag.  Otherwise we leave it at its initial state from
	 calling frag_align_code (0, 0), so that it does nothing.  */
      frag->fr_offset = bundle_align_p2;
      frag->fr_subtype = size - 1;
    }

  /* We do this every time rather than just in s_bundle_align_mode
     so that we catch any affected section without needing hooks all
     over for all paths that do section changes.  It's cheap enough.  */
  record_alignment (now_seg, bundle_align_p2 - OCTETS_PER_BYTE_POWER);
}

/* Assemble one instruction.  This takes care of the bundle features
   around calling md_assemble.  */
static void
assemble_one (char *line)
{
Roland McGrath's avatar
Roland McGrath committed
694
  fragS *insn_start_frag = NULL;
Roland McGrath's avatar
gas/  
Roland McGrath committed
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736

  if (bundle_lock_frchain != NULL && bundle_lock_frchain != frchain_now)
    {
      as_bad (_("cannot change section or subsection inside .bundle_lock"));
      /* Clearing this serves as a marker that we have already complained.  */
      bundle_lock_frchain = NULL;
    }

  if (bundle_lock_frchain == NULL && bundle_align_p2 > 0)
    insn_start_frag = start_bundle ();

  md_assemble (line);

  if (bundle_lock_frchain != NULL)
    {
      /* Make sure this hasn't pushed the locked sequence
	 past the bundle size.  */
      unsigned int bundle_size = pending_bundle_size (bundle_lock_frag);
      if (bundle_size > (1U << bundle_align_p2))
	as_bad (_("\
.bundle_lock sequence at %u bytes but .bundle_align_mode limit is %u bytes"),
		bundle_size, 1U << bundle_align_p2);
    }
  else if (bundle_align_p2 > 0)
    {
      unsigned int insn_size = pending_bundle_size (insn_start_frag);

      if (insn_size > (1U << bundle_align_p2))
	as_bad (_("\
single instruction is %u bytes long but .bundle_align_mode limit is %u"),
		(unsigned int) insn_size, 1U << bundle_align_p2);

      finish_bundle (insn_start_frag, insn_size);
    }
}

#else  /* !HANDLE_BUNDLE */

# define assemble_one(line) md_assemble(line)

#endif  /* HANDLE_BUNDLE */

Nick Clifton's avatar
Nick Clifton committed
737 738 739
/* We read the file, putting things into a web that represents what we
   have been reading.  */
void
Kazu Hirata's avatar
Kazu Hirata committed
740
read_a_source_file (char *name)
Richard Henderson's avatar
Richard Henderson committed
741
{
742 743 744
  char c;
  char *s;		/* String of symbol, '\0' appended.  */
  int temp;
Richard Henderson's avatar
Richard Henderson committed
745 746
  pseudo_typeS *pop;

747 748 749 750
#ifdef WARN_COMMENTS
  found_comment = 0;
#endif

Richard Henderson's avatar
Richard Henderson committed
751 752 753 754 755 756 757 758 759 760 761 762
  buffer = input_scrub_new_file (name);

  listing_file (name);
  listing_newline (NULL);
  register_dependency (name);

  /* Generate debugging information before we've read anything in to denote
     this file as the "main" source file and not a subordinate one
     (e.g. N_SO vs N_SOL in stabs).  */
  generate_file_debug ();

  while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0)
Nick Clifton's avatar
Nick Clifton committed
763
    {				/* We have another line to parse.  */
Jan Beulich's avatar
gas/  
Jan Beulich committed
764 765 766 767 768 769 770
#ifndef NO_LISTING
      /* In order to avoid listing macro expansion lines with labels
	 multiple times, keep track of which line was last issued.  */
      static char *last_eol;

      last_eol = NULL;
#endif
Richard Henderson's avatar
Richard Henderson committed
771 772
      while (input_line_pointer < buffer_limit)
	{
Alan Modra's avatar
Alan Modra committed
773
	  bfd_boolean was_new_line;
Nick Clifton's avatar
Nick Clifton committed
774
	  /* We have more of this buffer to parse.  */
Richard Henderson's avatar
Richard Henderson committed
775

Nick Clifton's avatar
Nick Clifton committed
776 777 778
	  /* We now have input_line_pointer->1st char of next line.
	     If input_line_pointer [-1] == '\n' then we just
	     scanned another line: so bump line counters.  */
Alan Modra's avatar
Alan Modra committed
779 780
	  was_new_line = is_end_of_line[(unsigned char) input_line_pointer[-1]];
	  if (was_new_line)
Richard Henderson's avatar
Richard Henderson committed
781
	    {
782
	      symbol_set_value_now (&dot_symbol);
Richard Henderson's avatar
Richard Henderson committed
783 784 785 786 787
#ifdef md_start_line_hook
	      md_start_line_hook ();
#endif
	      if (input_line_pointer[-1] == '\n')
		bump_line_counters ();
Alan Modra's avatar
Alan Modra committed
788
	    }
Richard Henderson's avatar
Richard Henderson committed
789

Alan Modra's avatar
Alan Modra committed
790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
#ifndef NO_LISTING
	  /* If listing is on, and we are expanding a macro, then give
	     the listing code the contents of the expanded line.  */
	  if (listing)
	    {
	      if ((listing & LISTING_MACEXP) && macro_nest > 0)
		{
		  /* Find the end of the current expanded macro line.  */
		  s = find_end_of_line (input_line_pointer, flag_m68k_mri);

		  if (s != last_eol)
		    {
		      char *copy;
		      int len;

		      last_eol = s;
		      /* Copy it for safe keeping.  Also give an indication of
			 how much macro nesting is involved at this point.  */
		      len = s - input_line_pointer;
		      copy = (char *) xmalloc (len + macro_nest + 2);
		      memset (copy, '>', macro_nest);
		      copy[macro_nest] = ' ';
		      memcpy (copy + macro_nest + 1, input_line_pointer, len);
		      copy[macro_nest + 1 + len] = '\0';

		      /* Install the line with the listing facility.  */
		      listing_newline (copy);
		    }
		}
	      else
		listing_newline (NULL);
	    }
#endif
	  if (was_new_line)
	    {
Richard Henderson's avatar
Richard Henderson committed
825 826
	      line_label = NULL;

827
	      if (LABELS_WITHOUT_COLONS || flag_m68k_mri)
Richard Henderson's avatar
Richard Henderson committed
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867
		{
		  /* Text at the start of a line must be a label, we
		     run down and stick a colon in.  */
		  if (is_name_beginner (*input_line_pointer))
		    {
		      char *line_start = input_line_pointer;
		      int mri_line_macro;

		      HANDLE_CONDITIONAL_ASSEMBLY ();

		      c = get_symbol_end ();

		      /* In MRI mode, the EQU and MACRO pseudoops must
			 be handled specially.  */
		      mri_line_macro = 0;
		      if (flag_m68k_mri)
			{
			  char *rest = input_line_pointer + 1;

			  if (*rest == ':')
			    ++rest;
			  if (*rest == ' ' || *rest == '\t')
			    ++rest;
			  if ((strncasecmp (rest, "EQU", 3) == 0
			       || strncasecmp (rest, "SET", 3) == 0)
			      && (rest[3] == ' ' || rest[3] == '\t'))
			    {
			      input_line_pointer = rest + 3;
			      equals (line_start,
				      strncasecmp (rest, "SET", 3) == 0);
			      continue;
			    }
			  if (strncasecmp (rest, "MACRO", 5) == 0
			      && (rest[5] == ' '
				  || rest[5] == '\t'
				  || is_end_of_line[(unsigned char) rest[5]]))
			    mri_line_macro = 1;
			}

		      /* In MRI mode, we need to handle the MACRO
868 869
			 pseudo-op specially: we don't want to put the
			 symbol in the symbol table.  */
Nick Clifton's avatar
Nick Clifton committed
870
		      if (!mri_line_macro
871
#ifdef TC_START_LABEL_WITHOUT_COLON
872 873
			  && TC_START_LABEL_WITHOUT_COLON(c,
							  input_line_pointer)
874
#endif
875
			  )
Richard Henderson's avatar
Richard Henderson committed
876 877 878 879 880 881 882 883 884 885 886 887 888 889
			line_label = colon (line_start);
		      else
			line_label = symbol_create (line_start,
						    absolute_section,
						    (valueT) 0,
						    &zero_address_frag);

		      *input_line_pointer = c;
		      if (c == ':')
			input_line_pointer++;
		    }
		}
	    }

Kazu Hirata's avatar
Kazu Hirata committed
890
	  /* We are at the beginning of a line, or similar place.
Nick Clifton's avatar
Nick Clifton committed
891 892
	     We expect a well-formed assembler statement.
	     A "symbol-name:" is a statement.
893

Nick Clifton's avatar
Nick Clifton committed
894 895
	     Depending on what compiler is used, the order of these tests
	     may vary to catch most common case 1st.
896 897 898
	     Each test is independent of all other tests at the (top)
	     level.  */
	  do
Nick Clifton's avatar
Nick Clifton committed
899
	    c = *input_line_pointer++;
900
	  while (c == '\t' || c == ' ' || c == '\f');
Richard Henderson's avatar
Richard Henderson committed
901

Nick Clifton's avatar
Nick Clifton committed
902 903
	  /* C is the 1st significant character.
	     Input_line_pointer points after that character.  */
Richard Henderson's avatar
Richard Henderson committed
904 905
	  if (is_name_beginner (c))
	    {
Nick Clifton's avatar
Nick Clifton committed
906
	      /* Want user-defined label or pseudo/opcode.  */
Richard Henderson's avatar
Richard Henderson committed
907 908 909
	      HANDLE_CONDITIONAL_ASSEMBLY ();

	      s = --input_line_pointer;
Nick Clifton's avatar
Nick Clifton committed
910 911 912
	      c = get_symbol_end ();	/* name's delimiter.  */

	      /* C is character after symbol.
913 914 915 916
		 That character's place in the input line is now '\0'.
		 S points to the beginning of the symbol.
		   [In case of pseudo-op, s->'.'.]
		 Input_line_pointer->'\0' where c was.  */
917
	      if (TC_START_LABEL (c, s, input_line_pointer))
Richard Henderson's avatar
Richard Henderson committed
918 919 920 921 922 923 924 925
		{
		  if (flag_m68k_mri)
		    {
		      char *rest = input_line_pointer + 1;

		      /* In MRI mode, \tsym: set 0 is permitted.  */
		      if (*rest == ':')
			++rest;
926

Richard Henderson's avatar
Richard Henderson committed
927 928
		      if (*rest == ' ' || *rest == '\t')
			++rest;
929

Richard Henderson's avatar
Richard Henderson committed
930 931 932 933 934 935 936 937 938 939
		      if ((strncasecmp (rest, "EQU", 3) == 0
			   || strncasecmp (rest, "SET", 3) == 0)
			  && (rest[3] == ' ' || rest[3] == '\t'))
			{
			  input_line_pointer = rest + 3;
			  equals (s, 1);
			  continue;
			}
		    }

Nick Clifton's avatar
Nick Clifton committed
940 941 942
		  line_label = colon (s);	/* User-defined label.  */
		  /* Put ':' back for error messages' sake.  */
		  *input_line_pointer++ = ':';
H.J. Lu's avatar
H.J. Lu committed
943 944 945
#ifdef tc_check_label
		  tc_check_label (line_label);
#endif
Nick Clifton's avatar
Nick Clifton committed
946
		  /* Input_line_pointer->after ':'.  */
Richard Henderson's avatar
Richard Henderson committed
947 948
		  SKIP_WHITESPACE ();
		}
Roland McGrath's avatar
gas/  
Roland McGrath committed
949
	      else if ((c == '=' && input_line_pointer[1] == '=')
950 951 952
		       || ((c == ' ' || c == '\t')
			   && input_line_pointer[1] == '='
			   && input_line_pointer[2] == '='))
953 954 955 956
		{
		  equals (s, -1);
		  demand_empty_rest_of_line ();
		}
Roland McGrath's avatar
gas/  
Roland McGrath committed
957 958 959
	      else if ((c == '='
		       || ((c == ' ' || c == '\t')
			    && input_line_pointer[1] == '='))
960
#ifdef TC_EQUAL_IN_INSN
Roland McGrath's avatar
gas/  
Roland McGrath committed
961
			   && !TC_EQUAL_IN_INSN (c, s)
962
#endif
Roland McGrath's avatar
gas/  
Roland McGrath committed
963
			   )
Richard Henderson's avatar
Richard Henderson committed
964 965 966 967 968
		{
		  equals (s, 1);
		  demand_empty_rest_of_line ();
		}
	      else
Nick Clifton's avatar
Nick Clifton committed
969 970
		{
		  /* Expect pseudo-op or machine instruction.  */
Richard Henderson's avatar
Richard Henderson committed
971 972
		  pop = NULL;

973
#ifndef TC_CASE_SENSITIVE
Richard Henderson's avatar
Richard Henderson committed
974 975
		  {
		    char *s2 = s;
976 977 978

		    strncpy (original_case_string, s2, sizeof (original_case_string));
		    original_case_string[sizeof (original_case_string) - 1] = 0;
979

Richard Henderson's avatar
Richard Henderson committed
980 981
		    while (*s2)
		      {
982
			*s2 = TOLOWER (*s2);
Richard Henderson's avatar
Richard Henderson committed
983 984 985 986
			s2++;
		      }
		  }
#endif
987
		  if (NO_PSEUDO_DOT || flag_m68k_mri)
Richard Henderson's avatar
Richard Henderson committed
988
		    {
Alan Modra's avatar
Alan Modra committed
989 990
		      /* The MRI assembler uses pseudo-ops without
			 a period.  */
Richard Henderson's avatar
Richard Henderson committed
991 992 993 994 995 996
		      pop = (pseudo_typeS *) hash_find (po_hash, s);
		      if (pop != NULL && pop->poc_handler == NULL)
			pop = NULL;
		    }

		  if (pop != NULL
Nick Clifton's avatar
Nick Clifton committed
997
		      || (!flag_m68k_mri && *s == '.'))
Richard Henderson's avatar
Richard Henderson committed
998
		    {
Nick Clifton's avatar
Nick Clifton committed
999
		      /* PSEUDO - OP.
1000

1001 1002 1003
			 WARNING: c has next char, which may be end-of-line.
			 We lookup the pseudo-op table with s+1 because we
			 already know that the pseudo-op begins with a '.'.  */
Richard Henderson's avatar
Richard Henderson committed
1004 1005 1006

		      if (pop == NULL)
			pop = (pseudo_typeS *) hash_find (po_hash, s + 1);
Nathan Sidwell's avatar
.:  
Nathan Sidwell committed
1007 1008
		      if (pop && !pop->poc_handler)
			pop = NULL;
Richard Henderson's avatar
Richard Henderson committed
1009 1010

		      /* In MRI mode, we may need to insert an
1011 1012
			 automatic alignment directive.  What a hack
			 this is.  */
Richard Henderson's avatar
Richard Henderson committed
1013 1014
		      if (mri_pending_align
			  && (pop == NULL
Nick Clifton's avatar
Nick Clifton committed
1015 1016 1017 1018
			      || !((pop->poc_handler == cons
				    && pop->poc_val == 1)
				   || (pop->poc_handler == s_space
				       && pop->poc_val == 1)
Richard Henderson's avatar
Richard Henderson committed
1019
#ifdef tc_conditional_pseudoop
Nick Clifton's avatar
Nick Clifton committed
1020
				   || tc_conditional_pseudoop (pop)
Richard Henderson's avatar
Richard Henderson committed
1021
#endif
Nick Clifton's avatar
Nick Clifton committed
1022 1023 1024 1025 1026 1027 1028 1029
				   || pop->poc_handler == s_if
				   || pop->poc_handler == s_ifdef
				   || pop->poc_handler == s_ifc
				   || pop->poc_handler == s_ifeqs
				   || pop->poc_handler == s_else
				   || pop->poc_handler == s_endif
				   || pop->poc_handler == s_globl
				   || pop->poc_handler == s_ignore)))
Richard Henderson's avatar
Richard Henderson committed
1030 1031 1032
			{
			  do_align (1, (char *) NULL, 0, 0);
			  mri_pending_align = 0;
1033

Richard Henderson's avatar
Richard Henderson committed
1034 1035
			  if (line_label != NULL)
			    {
1036
			      symbol_set_frag (line_label, frag_now);
Richard Henderson's avatar
Richard Henderson committed
1037 1038 1039 1040
			      S_SET_VALUE (line_label, frag_now_fix ());
			    }
			}

Nick Clifton's avatar
Nick Clifton committed
1041
		      /* Print the error msg now, while we still can.  */
Richard Henderson's avatar
Richard Henderson committed
1042 1043
		      if (pop == NULL)
			{
Jan Beulich's avatar
gas/  
Jan Beulich committed
1044 1045
			  char *end = input_line_pointer;

Richard Henderson's avatar
Richard Henderson committed
1046 1047
			  *input_line_pointer = c;
			  s_ignore (0);
Jan Beulich's avatar
gas/  
Jan Beulich committed
1048 1049 1050 1051 1052 1053 1054 1055
			  c = *--input_line_pointer;
			  *input_line_pointer = '\0';
			  if (! macro_defined || ! try_macro (c, s))
			    {
			      *end = '\0';
			      as_bad (_("unknown pseudo-op: `%s'"), s);
			      *input_line_pointer++ = c;
			    }
Richard Henderson's avatar
Richard Henderson committed
1056 1057 1058
			  continue;
			}

Nick Clifton's avatar
Nick Clifton committed
1059
		      /* Put it back for error messages etc.  */
Richard Henderson's avatar
Richard Henderson committed
1060 1061 1062
		      *input_line_pointer = c;
		      /* The following skip of whitespace is compulsory.
			 A well shaped space is sometimes all that separates
Nick Clifton's avatar
Nick Clifton committed
1063
			 keyword from operands.  */
Richard Henderson's avatar
Richard Henderson committed
1064 1065
		      if (c == ' ' || c == '\t')
			input_line_pointer++;
Nick Clifton's avatar
Nick Clifton committed
1066 1067

		      /* Input_line is restored.
1068 1069
			 Input_line_pointer->1st non-blank char
			 after pseudo-operation.  */
Richard Henderson's avatar
Richard Henderson committed
1070 1071 1072 1073 1074 1075 1076 1077
		      (*pop->poc_handler) (pop->poc_val);

		      /* If that was .end, just get out now.  */
		      if (pop->poc_handler == s_end)
			goto quit;
		    }
		  else
		    {
Nick Clifton's avatar
Nick Clifton committed
1078 1079
		      /* WARNING: c has char, which may be end-of-line.  */
		      /* Also: input_line_pointer->`\0` where c was.  */
Richard Henderson's avatar
Richard Henderson committed
1080
		      *input_line_pointer = c;
Nick Clifton's avatar
Nick Clifton committed
1081
		      input_line_pointer = _find_end_of_line (input_line_pointer, flag_m68k_mri, 1, 0);
Richard Henderson's avatar
Richard Henderson committed
1082 1083 1084 1085 1086
		      c = *input_line_pointer;
		      *input_line_pointer = '\0';

		      generate_lineno_debug ();

Jan Beulich's avatar
gas/  
Jan Beulich committed
1087 1088
		      if (macro_defined && try_macro (c, s))
			continue;
Richard Henderson's avatar
Richard Henderson committed
1089 1090 1091 1092 1093 1094 1095

		      if (mri_pending_align)
			{
			  do_align (1, (char *) NULL, 0, 0);
			  mri_pending_align = 0;
			  if (line_label != NULL)
			    {
1096
			      symbol_set_frag (line_label, frag_now);
Richard Henderson's avatar
Richard Henderson committed
1097 1098 1099 1100
			      S_SET_VALUE (line_label, frag_now_fix ());
			    }
			}

Roland McGrath's avatar
gas/  
Roland McGrath committed
1101
		      assemble_one (s); /* Assemble 1 instruction.  */
Richard Henderson's avatar
Richard Henderson committed
1102 1103 1104 1105

		      *input_line_pointer++ = c;

		      /* We resume loop AFTER the end-of-line from
Nick Clifton's avatar
Nick Clifton committed
1106 1107 1108
			 this instruction.  */
		    }
		}
Richard Henderson's avatar
Richard Henderson committed
1109
	      continue;
Nick Clifton's avatar
Nick Clifton committed
1110
	    }
Richard Henderson's avatar
Richard Henderson committed
1111 1112 1113 1114 1115

	  /* Empty statement?  */
	  if (is_end_of_line[(unsigned char) c])
	    continue;

1116
	  if ((LOCAL_LABELS_DOLLAR || LOCAL_LABELS_FB) && ISDIGIT (c))
Richard Henderson's avatar
Richard Henderson committed
1117
	    {
Nick Clifton's avatar
Nick Clifton committed
1118
	      /* local label  ("4:")  */
Richard Henderson's avatar
Richard Henderson committed
1119 1120 1121 1122 1123 1124
	      char *backup = input_line_pointer;

	      HANDLE_CONDITIONAL_ASSEMBLY ();

	      temp = c - '0';

Nick Clifton's avatar
Nick Clifton committed
1125
	      /* Read the whole number.  */
1126
	      while (ISDIGIT (*input_line_pointer))
Richard Henderson's avatar
Richard Henderson committed
1127 1128 1129
		{
		  temp = (temp * 10) + *input_line_pointer - '0';
		  ++input_line_pointer;
Nick Clifton's avatar
Nick Clifton committed
1130
		}
Richard Henderson's avatar
Richard Henderson committed
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159

	      if (LOCAL_LABELS_DOLLAR
		  && *input_line_pointer == '$'
		  && *(input_line_pointer + 1) == ':')
		{
		  input_line_pointer += 2;

		  if (dollar_label_defined (temp))
		    {
		      as_fatal (_("label \"%d$\" redefined"), temp);
		    }

		  define_dollar_label (temp);
		  colon (dollar_label_name (temp, 0));
		  continue;
		}

	      if (LOCAL_LABELS_FB
		  && *input_line_pointer++ == ':')
		{
		  fb_label_instance_inc (temp);
		  colon (fb_label_name (temp, 0));
		  continue;
		}

	      input_line_pointer = backup;
	    }			/* local label  ("4:") */

	  if (c && strchr (line_comment_chars, c))
Nick Clifton's avatar
Nick Clifton committed
1160
	    {			/* Its a comment.  Better say APP or NO_APP.  */
1161
	      sb sbuf;
Richard Henderson's avatar
Richard Henderson committed
1162 1163 1164 1165 1166 1167 1168 1169
	      char *ends;
	      char *new_buf;
	      char *new_tmp;
	      unsigned int new_length;
	      char *tmp_buf = 0;

	      s = input_line_pointer;
	      if (strncmp (s, "APP\n", 4))
Nick Clifton's avatar
Nick Clifton committed
1170 1171 1172 1173 1174 1175
		{
		  /* We ignore it.  */
		  ignore_rest_of_line ();
		  continue;
		}
	      bump_line_counters ();
Richard Henderson's avatar
Richard Henderson committed
1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187
	      s += 4;

	      ends = strstr (s, "#NO_APP\n");

	      if (!ends)
		{
		  unsigned int tmp_len;
		  unsigned int num;

		  /* The end of the #APP wasn't in this buffer.  We
		     keep reading in buffers until we find the #NO_APP
		     that goes with this #APP  There is one.  The specs
Kazu Hirata's avatar
Kazu Hirata committed
1188
		     guarantee it...  */
Richard Henderson's avatar
Richard Henderson committed
1189
		  tmp_len = buffer_limit - s;
1190
		  tmp_buf = (char *) xmalloc (tmp_len + 1);
Richard Henderson's avatar
Richard Henderson committed
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205
		  memcpy (tmp_buf, s, tmp_len);
		  do
		    {
		      new_tmp = input_scrub_next_buffer (&buffer);
		      if (!new_tmp)
			break;
		      else
			buffer_limit = new_tmp;
		      input_line_pointer = buffer;
		      ends = strstr (buffer, "#NO_APP\n");
		      if (ends)
			num = ends - buffer;
		      else
			num = buffer_limit - buffer;

1206
		      tmp_buf = (char *) xrealloc (tmp_buf, tmp_len + num);
Richard Henderson's avatar
Richard Henderson committed
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230
		      memcpy (tmp_buf + tmp_len, buffer, num);
		      tmp_len += num;
		    }
		  while (!ends);

		  input_line_pointer = ends ? ends + 8 : NULL;

		  s = tmp_buf;
		  ends = s + tmp_len;

		}
	      else
		{
		  input_line_pointer = ends + 8;
		}

	      scrub_string = s;
	      scrub_string_end = ends;

	      new_length = ends - s;
	      new_buf = (char *) xmalloc (new_length);
	      new_tmp = new_buf;
	      for (;;)
		{
Alan Modra's avatar
Alan Modra committed
1231 1232
		  size_t space;
		  size_t size;
Richard Henderson's avatar
Richard Henderson committed
1233 1234 1235 1236 1237 1238

		  space = (new_buf + new_length) - new_tmp;
		  size = do_scrub_chars (scrub_from_string, new_tmp, space);

		  if (size < space)
		    {
1239
		      new_tmp[size] = 0;
Richard Henderson's avatar
Richard Henderson committed
1240 1241 1242
		      break;
		    }

1243
		  new_buf = (char *) xrealloc (new_buf, new_length + 100);
Richard Henderson's avatar
Richard Henderson committed
1244 1245 1246 1247 1248 1249
		  new_tmp = new_buf + new_length;
		  new_length += 100;
		}

	      if (tmp_buf)
		free (tmp_buf);
1250

1251 1252 1253 1254 1255 1256 1257
	      /* We've "scrubbed" input to the preferred format.  In the
		 process we may have consumed the whole of the remaining
		 file (and included files).  We handle this formatted
		 input similar to that of macro expansion, letting
		 actual macro expansion (possibly nested) and other
		 input expansion work.  Beware that in messages, line
		 numbers and possibly file names will be incorrect.  */
1258 1259 1260
	      new_length = strlen (new_buf);
	      sb_build (&sbuf, new_length);
	      sb_add_buffer (&sbuf, new_buf, new_length);
1261 1262 1263 1264
	      input_scrub_include_sb (&sbuf, input_line_pointer, 0);
	      sb_kill (&sbuf);
	      buffer_limit = input_scrub_next_buffer (&input_line_pointer);
	      free (new_buf);
Richard Henderson's avatar
Richard Henderson committed
1265 1266 1267 1268 1269 1270 1271 1272 1273
	      continue;
	    }

	  HANDLE_CONDITIONAL_ASSEMBLY ();

#ifdef tc_unrecognized_line
	  if (tc_unrecognized_line (c))
	    continue;
#endif
1274
	  input_line_pointer--;
Nick Clifton's avatar
Nick Clifton committed
1275
	  /* Report unknown char as error.  */
1276
	  demand_empty_rest_of_line ();
Nick Clifton's avatar
Nick Clifton committed
1277 1278
	}
    }
Richard Henderson's avatar
Richard Henderson committed
1279 1280

 quit:
1281
  symbol_set_value_now (&dot_symbol);
Richard Henderson's avatar
Richard Henderson committed
1282

Roland McGrath's avatar
gas/  
Roland McGrath committed
1283 1284 1285 1286 1287 1288 1289
#ifdef HANDLE_BUNDLE
  if (bundle_lock_frag != NULL)
    {
      as_bad_where (bundle_lock_frag->fr_file, bundle_lock_frag->fr_line,
		    _(".bundle_lock with no matching .bundle_unlock"));
      bundle_lock_frag = NULL;
      bundle_lock_frchain = NULL;
Roland McGrath's avatar
gas/  
Roland McGrath committed
1290
      bundle_lock_depth = 0;
Roland McGrath's avatar
gas/  
Roland McGrath committed
1291 1292 1293
    }
#endif

Richard Henderson's avatar
Richard Henderson committed
1294
#ifdef md_cleanup
Nick Clifton's avatar
Nick Clifton committed
1295
  md_cleanup ();
Richard Henderson's avatar
Richard Henderson committed
1296
#endif
Nick Clifton's avatar
Nick Clifton committed
1297 1298
  /* Close the input file.  */
  input_scrub_close ();
1299 1300 1301 1302 1303 1304 1305
#ifdef WARN_COMMENTS
  {
    if (warn_comment && found_comment)
      as_warn_where (found_comment_file, found_comment,
		     "first comment found here");
  }
#endif
Richard Henderson's avatar
Richard Henderson committed
1306 1307
}

1308
/* Convert O_constant expression EXP into the equivalent O_big representation.
Julian Brown's avatar
Julian Brown committed
1309
   Take the sign of the number from SIGN rather than X_add_number.  */
1310 1311

static void
Julian Brown's avatar
Julian Brown committed
1312
convert_to_bignum (expressionS *exp, int sign)
1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324
{
  valueT value;
  unsigned int i;

  value = exp->X_add_number;
  for (i = 0; i < sizeof (exp->X_add_number) / CHARS_PER_LITTLENUM; i++)
    {
      generic_bignum[i] = value & LITTLENUM_MASK;
      value >>= LITTLENUM_NUMBER_OF_BITS;
    }
  /* Add a sequence of sign bits if the top bit of X_add_number is not
     the sign of the original value.  */
Julian Brown's avatar
Julian Brown committed
1325 1326
  if ((exp->X_add_number < 0) == !sign)
    generic_bignum[i++] = sign ? LITTLENUM_MASK : 0;
1327 1328 1329 1330
  exp->X_op = O_big;
  exp->X_add_number = i;
}

Richard Henderson's avatar
Richard Henderson committed
1331 1332 1333 1334 1335 1336 1337 1338 1339
/* For most MRI pseudo-ops, the line actually ends at the first
   nonquoted space.  This function looks for that point, stuffs a null
   in, and sets *STOPCP to the character that used to be there, and
   returns the location.

   Until I hear otherwise, I am going to assume that this is only true
   for the m68k MRI assembler.  */

char *
Kazu Hirata's avatar
Kazu Hirata committed
1340
mri_comment_field (char *stopcp)
Richard Henderson's avatar
Richard Henderson committed
1341 1342
{
  char *s;
Nick Clifton's avatar
Nick Clifton committed
1343
#ifdef TC_M68K
Richard Henderson's avatar
Richard Henderson committed
1344 1345 1346 1347 1348
  int inquote = 0;

  know (flag_m68k_mri);

  for (s = input_line_pointer;
Nick Clifton's avatar
Nick Clifton committed
1349
       ((!is_end_of_line[(unsigned char) *s] && *s != ' ' && *s != '\t')
Richard Henderson's avatar
Richard Henderson committed
1350 1351 1352 1353
	|| inquote);
       s++)
    {
      if (*s == '\'')
Nick Clifton's avatar
Nick Clifton committed
1354
	inquote = !inquote;
Richard Henderson's avatar
Richard Henderson committed
1355 1356
    }
#else
Nick Clifton's avatar
Nick Clifton committed
1357 1358 1359
  for (s = input_line_pointer;
       !is_end_of_line[(unsigned char) *s];
       s++)
Richard Henderson's avatar
Richard Henderson committed
1360
    ;
Nick Clifton's avatar
Nick Clifton committed
1361
#endif
Richard Henderson's avatar
Richard Henderson committed
1362 1363
  *stopcp = *s;
  *s = '\0';
1364

Richard Henderson's avatar
Richard Henderson committed
1365 1366 1367 1368 1369 1370
  return s;
}

/* Skip to the end of an MRI comment field.  */

void
Kazu Hirata's avatar
Kazu Hirata committed
1371
mri_comment_end (char *stop, int stopc)
Richard Henderson's avatar
Richard Henderson committed
1372 1373 1374 1375 1376
{
  know (flag_mri);

  input_line_pointer = stop;
  *stop = stopc;
Nick Clifton's avatar
Nick Clifton committed
1377
  while (!is_end_of_line[(unsigned char) *input_line_pointer])
Richard Henderson's avatar
Richard Henderson committed
1378 1379 1380
    ++input_line_pointer;
}

Nick Clifton's avatar
Nick Clifton committed
1381
void
Kazu Hirata's avatar
Kazu Hirata committed
1382
s_abort (int ignore ATTRIBUTE_UNUSED)
Richard Henderson's avatar
Richard Henderson committed
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392
{
  as_fatal (_(".abort detected.  Abandoning ship."));
}

/* Guts of .align directive.  N is the power of two to which to align.
   FILL may be NULL, or it may point to the bytes of the fill pattern.
   LEN is the length of whatever FILL points to, if anything.  MAX is
   the maximum number of characters to skip when doing the alignment,
   or 0 if there is no maximum.  */

Nick Clifton's avatar
Nick Clifton committed
1393
static void
Kazu Hirata's avatar
Kazu Hirata committed
1394
do_align (int n, char *fill, int len, int max)
Richard Henderson's avatar
Richard Henderson committed
1395
{
1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408
  if (now_seg == absolute_section)
    {
      if (fill != NULL)
	while (len-- > 0)
	  if (*fill++ != '\0')
	    {
	      as_warn (_("ignoring fill value in absolute section"));
	      break;
	    }
      fill = NULL;
      len = 0;
    }

1409 1410 1411
#ifdef md_flush_pending_output
  md_flush_pending_output ();
#endif
Richard Henderson's avatar
Richard Henderson committed
1412 1413 1414 1415
#ifdef md_do_align
  md_do_align (n, fill, len, max, just_record_alignment);
#endif

Nick Clifton's avatar
Nick Clifton committed
1416
  /* Only make a frag if we HAVE to...  */
Richard Henderson's avatar
Richard Henderson committed
1417 1418
  if (n != 0 && !need_pass_2)
    {
1419 1420 1421 1422 1423 1424 1425 1426
      if (fill == NULL)
	{
	  if (subseg_text_p (now_seg))
	    frag_align_code (n, max);
	  else
	    frag_align (n, 0, max);
	}
      else if (len <= 1)
Richard Henderson's avatar
Richard Henderson committed
1427 1428 1429 1430 1431 1432
	frag_align (n, *fill, max);
      else
	frag_align_pattern (n, fill, len, max);
    }

#ifdef md_do_align
1433
 just_record_alignment: ATTRIBUTE_UNUSED_LABEL
Richard Henderson's avatar
Richard Henderson committed
1434 1435
#endif

1436
  record_alignment (now_seg, n - OCTETS_PER_BYTE_POWER);
Richard Henderson's avatar
Richard Henderson committed
1437 1438 1439 1440 1441 1442
}

/* Handle the .align pseudo-op.  A positive ARG is a default alignment
   (in bytes).  A negative ARG is the negative of the length of the
   fill pattern.  BYTES_P is non-zero if the alignment value should be
   interpreted as the byte boundary, rather than the power of 2.  */
Danny Smith's avatar
Danny Smith committed
1443 1444 1445
#ifndef TC_ALIGN_LIMIT
#define TC_ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1)
#endif
1446

Richard Henderson's avatar
Richard Henderson committed
1447
static void
Kazu Hirata's avatar
Kazu Hirata committed
1448
s_align (int arg, int bytes_p)
Richard Henderson's avatar
Richard Henderson committed
1449
{
Danny Smith's avatar
Danny Smith committed
1450
  unsigned int align_limit = TC_ALIGN_LIMIT;
1451
  unsigned int align;
Richard Henderson's avatar
Richard Henderson committed
1452
  char *stop = NULL;
1453
  char stopc = 0;
Richard Henderson's avatar
Richard Henderson committed
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465
  offsetT fill = 0;
  int max;
  int fill_p;

  if (flag_mri)
    stop = mri_comment_field (&stopc);

  if (is_end_of_line[(unsigned char) *input_line_pointer])
    {
      if (arg < 0)
	align = 0;
      else
Nick Clifton's avatar
Nick Clifton committed
1466
	align = arg;	/* Default value from pseudo-op table.  */
Richard Henderson's avatar
Richard Henderson committed
1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483
    }
  else
    {
      align = get_absolute_expression ();
      SKIP_WHITESPACE ();
    }

  if (bytes_p)
    {
      /* Convert to a power of 2.  */
      if (align != 0)
	{
	  unsigned int i;

	  for (i = 0; (align & 1) == 0; align >>= 1, ++i)
	    ;
	  if (align != 1)
1484
	    as_bad (_("alignment not a power of 2"));
1485

Richard Henderson's avatar
Richard Henderson committed
1486 1487 1488 1489
	  align = i;
	}
    }

1490
  if (align > align_limit)
Richard Henderson's avatar
Richard Henderson committed
1491
    {
1492
      align = align_limit;
1493
      as_warn (_("alignment too large: %u assumed"), align);
Richard Henderson's avatar
Richard Henderson committed
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505