X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gas%2Fmacro.c;h=cddf26ab79ea23599d449f5b817f508181aa7907;hb=39a0d071ae10ab953d6bb986ec40996c771db78f;hp=4589bd8455db009ff914fd79562dba3e20954cd6;hpb=4b95cf5c0c75d6efc1b2f96af72317aecca079f1;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/macro.c b/gas/macro.c index 4589bd8455..cddf26ab79 100644 --- a/gas/macro.c +++ b/gas/macro.c @@ -1,5 +1,5 @@ /* macro.c - macro support for gas - Copyright (C) 1994-2014 Free Software Foundation, Inc. + Copyright (C) 1994-2016 Free Software Foundation, Inc. Written by Steve and Judy Chamberlain of Cygnus Support, sac@cygnus.com @@ -211,6 +211,28 @@ buffer_and_nest (const char *from, const char *to, sb *ptr, break; } } + + /* PR gas/16908 + Apply and discard .linefile directives that appear within + the macro. For long macros, one might want to report the + line number information associated with the lines within + the macro definition, but we would need more infrastructure + to make that happen correctly (e.g. resetting the line + number when expanding the macro), and since for short + macros we clearly prefer reporting the point of expansion + anyway, there's not an obviously better fix here. */ + if (strncasecmp (ptr->ptr + i, "linefile", 8) == 0) + { + char *saved_input_line_pointer = input_line_pointer; + char saved_eol_char = ptr->ptr[ptr->len]; + + ptr->ptr[ptr->len] = '\0'; + input_line_pointer = ptr->ptr + i + 8; + s_app_line (0); + ptr->ptr[ptr->len] = saved_eol_char; + input_line_pointer = saved_input_line_pointer; + ptr->len = line_start; + } } /* Add the original end-of-line char to the end and keep running. */ @@ -626,7 +648,7 @@ free_macro (macro_entry *macro) const char * define_macro (size_t idx, sb *in, sb *label, size_t (*get_line) (sb *), - char *file, unsigned int line, + const char *file, unsigned int line, const char **namep) { macro_entry *macro; @@ -1228,13 +1250,14 @@ check_macro (const char *line, sb *expand, if (is_name_ender (*s)) ++s; - copy = (char *) alloca (s - line + 1); + copy = (char *) xmalloc (s - line + 1); memcpy (copy, line, s - line); copy[s - line] = '\0'; for (cls = copy; *cls != '\0'; cls ++) *cls = TOLOWER (*cls); macro = (macro_entry *) hash_find (macro_hash, copy); + free (copy); if (macro == NULL) return 0; @@ -1266,7 +1289,7 @@ delete_macro (const char *name) macro_entry *macro; len = strlen (name); - copy = (char *) alloca (len + 1); + copy = (char *) xmalloc (len + 1); for (i = 0; i < len; ++i) copy[i] = TOLOWER (name[i]); copy[i] = '\0'; @@ -1281,6 +1304,7 @@ delete_macro (const char *name) } else as_warn (_("Attempt to purge non-existant macro `%s'"), copy); + free (copy); } /* Handle the MRI IRP and IRPC pseudo-ops. These are handled as a