* objdump.c (disassemble_data): Initialize prevline to 0. Make

prev_function non const.  Copy functionname into an malloc buffer
	when setting prev_function, instead of assuming that the string
	will last forever.
This commit is contained in:
Ian Lance Taylor
1994-09-14 20:21:21 +00:00
parent 9be909aef7
commit e4798f4093
2 changed files with 15 additions and 5 deletions

View File

@@ -1,5 +1,10 @@
Wed Sep 14 12:19:07 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) Wed Sep 14 12:19:07 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
* objdump.c (disassemble_data): Initialize prevline to 0. Make
prev_function non const. Copy functionname into an malloc buffer
when setting prev_function, instead of assuming that the string
will last forever.
* nm.c: Include libiberty.h. * nm.c: Include libiberty.h.
(sort_by_size): New static variable. (sort_by_size): New static variable.
(long_options): Add --size-sort. (long_options): Add --size-sort.

View File

@@ -451,8 +451,8 @@ disassemble_data (abfd)
struct disassemble_info disasm_info; struct disassemble_info disasm_info;
struct objdump_disasm_info aux; struct objdump_disasm_info aux;
int prevline; int prevline = 0;
CONST char *prev_function = ""; char *prev_function = NULL;
asection *section; asection *section;
@@ -561,11 +561,16 @@ disassemble_data (abfd)
&functionname, &functionname,
&line)) &line))
{ {
if (functionname && *functionname if (functionname
&& strcmp(functionname, prev_function)) && *functionname != '\0'
&& (prev_function == NULL
|| strcmp (functionname, prev_function) != 0))
{ {
printf ("%s():\n", functionname); printf ("%s():\n", functionname);
prev_function = functionname; if (prev_function != NULL)
free (prev_function);
prev_function = xmalloc (strlen (functionname) + 1);
strcpy (prev_function, functionname);
} }
if (!filename) if (!filename)
filename = "???"; filename = "???";