(app_push): Save saved_input in allocated buffer.
(app_pop): Restored saved_input.
(do_scrub_chars): Change get parameter to take char * and int as
arguments. Change GET macro to pass input_buffer to get
function. Don't save input into allocated buffer.
* as.h (do_scrub_chars): Update declaration.
* input-file.c (input_file_get): Change to take char * and int.
Read data into passed in buffer. Remove static buffer.
* read.c (scrub_from_string): Change to take char * and int. Copy
data into passed in buffer.
static int add_newlines;
static char *saved_input;
static int saved_input_len;
+static char input_buffer[32 * 1024];
static const char *mri_state;
static char mri_last_ch;
saved->out_string = out_string;
memcpy (saved->out_buf, out_buf, sizeof (out_buf));
saved->add_newlines = add_newlines;
- saved->saved_input = saved_input;
- saved->saved_input_len = saved_input_len;
+ if (saved_input == NULL)
+ saved->saved_input = NULL;
+ else
+ {
+ saved->saved_input = xmalloc (saved_input_len);
+ memcpy (saved->saved_input, saved_input, saved_input_len);
+ saved->saved_input_len = saved_input_len;
+ }
saved->scrub_m68k_mri = scrub_m68k_mri;
saved->mri_state = mri_state;
saved->mri_last_ch = mri_last_ch;
out_string = saved->out_string;
memcpy (out_buf, saved->out_buf, sizeof (out_buf));
add_newlines = saved->add_newlines;
- saved_input = saved->saved_input;
- saved_input_len = saved->saved_input_len;
+ if (saved->saved_input == NULL)
+ saved_input = NULL;
+ else
+ {
+ assert (saved->saved_input_len <= sizeof input_buffer);
+ memcpy (input_buffer, saved->saved_input, saved->saved_input_len);
+ saved_input = input_buffer;
+ saved_input_len = saved->saved_input_len;
+ free (saved->saved_input);
+ }
scrub_m68k_mri = saved->scrub_m68k_mri;
mri_state = saved->mri_state;
mri_last_ch = saved->mri_last_ch;
int
do_scrub_chars (get, tostart, tolen)
- int (*get) PARAMS ((char **));
+ int (*get) PARAMS ((char *, int));
char *tostart;
int tolen;
{
/* This macro gets the next input character. */
-#define GET() \
- (from < fromend \
- ? * (unsigned char *) (from++) \
- : ((saved_input != NULL \
- ? (free (saved_input), \
- saved_input = NULL, \
- 0) \
- : 0), \
- fromlen = (*get) (&from), \
- fromend = from + fromlen, \
- (fromlen == 0 \
- ? EOF \
+#define GET() \
+ (from < fromend \
+ ? * (unsigned char *) (from++) \
+ : (saved_input = NULL, \
+ fromlen = (*get) (input_buffer, sizeof input_buffer), \
+ from = input_buffer, \
+ fromend = from + fromlen, \
+ (fromlen == 0 \
+ ? EOF \
: * (unsigned char *) (from++))))
/* This macro pushes a character back on the input stream. */
}
else
{
- fromlen = (*get) (&from);
+ fromlen = (*get) (input_buffer, sizeof input_buffer);
if (fromlen == 0)
return 0;
+ from = input_buffer;
fromend = from + fromlen;
}
processed. */
if (fromend > from)
{
- char *save;
-
- save = (char *) xmalloc (fromend - from);
- memcpy (save, from, fromend - from);
- if (saved_input != NULL)
- free (saved_input);
- saved_input = save;
+ saved_input = from;
saved_input_len = fromend - from;
}
else
- {
- if (saved_input != NULL)
- {
- free (saved_input);
- saved_input = NULL;
- }
- }
+ saved_input = NULL;
+
return to - tostart;
}
/* as.h - global header file
- Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 1998
+ Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
char *input_scrub_include_file PARAMS ((char *filename, char *position));
char *input_scrub_new_file PARAMS ((char *filename));
char *input_scrub_next_buffer PARAMS ((char **bufp));
-int do_scrub_chars PARAMS ((int (*get) (char **), char *to, int tolen));
+int do_scrub_chars PARAMS ((int (*get) (char *, int), char *to, int tolen));
int gen_to_words PARAMS ((LITTLENUM_TYPE * words, int precision,
long exponent_bits));
int had_err PARAMS ((void));
struct expressionS;
struct fix;
-struct symbol;
+typedef struct symbol symbolS;
struct relax_type;
typedef struct frag fragS;
#ifdef BFD_ASSEMBLER
/* literal.c */
-valueT add_to_literal_pool PARAMS ((struct symbol *, valueT, segT, int));
+valueT add_to_literal_pool PARAMS ((symbolS *, valueT, segT, int));
#endif
int check_eh_frame PARAMS ((struct expressionS *, unsigned int *));
/* this one starts the chain of target dependant headers */
#include "targ-env.h"
-#include "struc-symbol.h"
#include "write.h"
#include "frags.h"
#include "hash.h"
/* input_file.c - Deal with Input Files -
- Copyright (C) 1987, 1990, 1991, 1992, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 98, 1999
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GNU General Public License for more details.
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ along with GAS; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
/*
* Confines all details of reading source bytes to this module.
#include "as.h"
#include "input-file.h"
-static int input_file_get PARAMS ((char **));
+static int input_file_get PARAMS ((char *, int));
/* This variable is non-zero if the file currently being read should be
preprocessed by app. It is zero if the file can be read straight in.
/* This function is passed to do_scrub_chars. */
static int
-input_file_get (from)
- char **from;
+input_file_get (buf, buflen)
+ char *buf;
+ int buflen;
{
- static char buf[BUFFER_SIZE];
int size;
- size = fread (buf, sizeof (char), sizeof buf, f_in);
+ size = fread (buf, sizeof (char), buflen, f_in);
if (size < 0)
{
as_perror (_("Can't read from %s"), file_name);
size = 0;
}
- *from = buf;
return size;
}
#endif
static void cons_worker PARAMS ((int, int));
-static int scrub_from_string PARAMS ((char **));
+static int scrub_from_string PARAMS ((char *, int));
static void do_align PARAMS ((int, char *, int, int));
static void s_align PARAMS ((int, int));
static void s_lcomm_internal PARAMS ((int, int));
static char *scrub_string_end;
static int
-scrub_from_string (from)
- char **from;
+scrub_from_string (buf, buflen)
+ char *buf;
+ int buflen;
{
- int size;
-
- *from = scrub_string;
- size = scrub_string_end - scrub_string;
- scrub_string = scrub_string_end;
- return size;
+ int copy;
+
+ copy = scrub_string_end - scrub_string;
+ if (copy > buflen)
+ copy = buflen;
+ memcpy (buf, scrub_string, copy);
+ scrub_string += copy;
+ return copy;
}
/* read_a_source_file()
mri_pending_align = 0;
if (line_label != NULL)
{
- line_label->sy_frag = frag_now;
+ symbol_set_frag (line_label, frag_now);
S_SET_VALUE (line_label, frag_now_fix ());
}
}
mri_pending_align = 0;
if (line_label != NULL)
{
- line_label->sy_frag = frag_now;
+ symbol_set_frag (line_label, frag_now);
S_SET_VALUE (line_label, frag_now_fix ());
}
}
if (line_label != NULL)
{
- line_label->sy_value.X_op = O_symbol;
- line_label->sy_value.X_add_symbol = sym;
- line_label->sy_value.X_add_number = S_GET_VALUE (sym);
- line_label->sy_frag = &zero_address_frag;
+ expressionS exp;
+ exp.X_op = O_symbol;
+ exp.X_add_symbol = sym;
+ exp.X_add_number = 0;
+ symbol_set_value_expression (line_label, &exp);
+ symbol_set_frag (line_label, &zero_address_frag);
S_SET_SEGMENT (line_label, expr_section);
}
frag_align (align, 0, 0);
/* detach from old frag */
if (S_GET_SEGMENT (symbolP) == bss_seg)
- symbolP->sy_frag->fr_symbol = NULL;
+ symbol_get_frag (symbolP)->fr_symbol = NULL;
- symbolP->sy_frag = frag_now;
+ symbol_set_frag (symbolP, frag_now);
pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP,
(offsetT) temp, (char *) 0);
*pfrag = 0;
{
S_SET_SEGMENT (line_label, undefined_section);
S_SET_VALUE (line_label, 0);
- line_label->sy_frag = &zero_address_frag;
+ symbol_set_frag (line_label, &zero_address_frag);
}
if (((flag_m68k_mri
S_SET_VALUE (mri_common_symbol, val + 1);
if (line_label != NULL)
{
- know (line_label->sy_value.X_op == O_symbol);
- know (line_label->sy_value.X_add_symbol == mri_common_symbol);
- line_label->sy_value.X_add_number += 1;
+ expressionS *symexp;
+
+ symexp = symbol_get_value_expression (line_label);
+ know (symexp->X_op == O_symbol);
+ know (symexp->X_add_symbol == mri_common_symbol);
+ symexp->X_add_number += 1;
}
}
}
do_align (1, (char *) NULL, 0, 0);
if (line_label != NULL)
{
- line_label->sy_frag = frag_now;
+ symbol_set_frag (line_label, frag_now);
S_SET_VALUE (line_label, frag_now_fix ());
}
}
&& (S_GET_SEGMENT (exp.X_add_symbol)
== S_GET_SEGMENT (exp.X_op_symbol))
&& SEG_NORMAL (S_GET_SEGMENT (exp.X_add_symbol))
- && exp.X_add_symbol->sy_frag == exp.X_op_symbol->sy_frag)
+ && (symbol_get_frag (exp.X_add_symbol)
+ == symbol_get_frag (exp.X_op_symbol)))
{
exp.X_op = O_constant;
exp.X_add_number = (S_GET_VALUE (exp.X_add_symbol)
#endif /* OBJ_AOUT or OBJ_BOUT */
S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
if (exp.X_op != O_constant)
- symbolP->sy_frag = &zero_address_frag;
+ symbol_set_frag (symbolP, &zero_address_frag);
break;
case O_register:
S_SET_SEGMENT (symbolP, reg_section);
S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
- symbolP->sy_frag = &zero_address_frag;
+ symbol_set_frag (symbolP, &zero_address_frag);
break;
case O_symbol:
if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section
|| exp.X_add_number != 0)
- symbolP->sy_value = exp;
+ symbol_set_value_expression (symbolP, &exp);
else
{
symbolS *s = exp.X_add_symbol;
#endif /* OBJ_AOUT or OBJ_BOUT */
S_SET_VALUE (symbolP,
exp.X_add_number + S_GET_VALUE (s));
- symbolP->sy_frag = s->sy_frag;
+ symbol_set_frag (symbolP, symbol_get_frag (s));
copy_symbol_attributes (symbolP, s);
}
break;
default:
/* The value is some complex expression.
FIXME: Should we set the segment to anything? */
- symbolP->sy_value = exp;
+ symbol_set_value_expression (symbolP, &exp);
break;
}
}
/* Handle a negative bignum. */
if (op == O_uminus
&& exp->X_add_number == 0
- && exp->X_add_symbol->sy_value.X_op == O_big
- && exp->X_add_symbol->sy_value.X_add_number > 0)
+ && symbol_get_value_expression (exp->X_add_symbol)->X_op == O_big
+ && symbol_get_value_expression (exp->X_add_symbol)->X_add_number > 0)
{
int i;
unsigned long carry;
- exp = &exp->X_add_symbol->sy_value;
+ exp = symbol_get_value_expression (exp->X_add_symbol);
/* Negate the bignum: one's complement each digit and add 1. */
carry = 1;