diff options
author | Ian Lance Taylor <ian@airs.com> | 1999-06-03 00:24:14 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1999-06-03 00:24:14 +0000 |
commit | 2b47531bf9ef778773831ecb1b43186e95ffe8d7 (patch) | |
tree | 684eca49faf900f0045c5a6c14670c6cb1dcfa51 | |
parent | 1af6dcd2bb59d35b0a2cd2e7898831e685bc043f (diff) | |
download | gdb-2b47531bf9ef778773831ecb1b43186e95ffe8d7.zip gdb-2b47531bf9ef778773831ecb1b43186e95ffe8d7.tar.gz gdb-2b47531bf9ef778773831ecb1b43186e95ffe8d7.tar.bz2 |
* app.c (input_buffer): New static variable.
(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.
-rw-r--r-- | gas/app.c | 66 | ||||
-rw-r--r-- | gas/as.h | 9 | ||||
-rw-r--r-- | gas/input-file.c | 19 | ||||
-rw-r--r-- | gas/read.c | 71 |
4 files changed, 88 insertions, 77 deletions
@@ -191,6 +191,7 @@ static char out_buf[20]; 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; @@ -227,8 +228,14 @@ app_push () 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; @@ -256,8 +263,16 @@ app_pop (arg) 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; @@ -308,7 +323,7 @@ process_escape (ch) int do_scrub_chars (get, tostart, tolen) - int (*get) PARAMS ((char **)); + int (*get) PARAMS ((char *, int)); char *tostart; int tolen; { @@ -357,18 +372,15 @@ do_scrub_chars (get, tostart, 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. */ @@ -400,9 +412,10 @@ do_scrub_chars (get, tostart, tolen) } else { - fromlen = (*get) (&from); + fromlen = (*get) (input_buffer, sizeof input_buffer); if (fromlen == 0) return 0; + from = input_buffer; fromend = from + fromlen; } @@ -1232,23 +1245,12 @@ do_scrub_chars (get, tostart, tolen) 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; } @@ -1,5 +1,5 @@ /* 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. @@ -559,7 +559,7 @@ char *atof_ieee PARAMS ((char *str, int what_kind, LITTLENUM_TYPE * words)); 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)); @@ -592,13 +592,13 @@ void print_dependencies 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 *)); @@ -611,7 +611,6 @@ void eh_frame_convert_frag PARAMS ((fragS *)); /* 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" diff --git a/gas/input-file.c b/gas/input-file.c index c63f7c9..634f6f7 100644 --- a/gas/input-file.c +++ b/gas/input-file.c @@ -1,5 +1,6 @@ /* 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. @@ -14,8 +15,9 @@ 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. @@ -30,7 +32,7 @@ #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. @@ -191,19 +193,18 @@ input_file_close () /* 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; } @@ -208,7 +208,7 @@ static int dwarf_file_string; #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)); @@ -480,15 +480,18 @@ static char *scrub_string; 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() @@ -788,7 +791,7 @@ read_a_source_file (name) 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 ()); } } @@ -869,7 +872,7 @@ read_a_source_file (name) 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 ()); } } @@ -1489,10 +1492,12 @@ s_mri_common (small) 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); } @@ -2064,9 +2069,9 @@ s_lcomm_internal (needs_align, bytes_p) 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; @@ -2261,7 +2266,7 @@ s_macro (ignore) { 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 @@ -2783,9 +2788,12 @@ s_space (mult) 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; } } } @@ -2794,7 +2802,7 @@ s_space (mult) 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 ()); } } @@ -3114,7 +3122,8 @@ pseudo_set (symbolP) && (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) @@ -3138,19 +3147,19 @@ pseudo_set (symbolP) #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; @@ -3164,7 +3173,7 @@ pseudo_set (symbolP) #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; @@ -3172,7 +3181,7 @@ pseudo_set (symbolP) 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; } } @@ -3401,13 +3410,13 @@ emit_expr (exp, nbytes) /* 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; |