aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1994-09-14 20:21:21 +0000
committerIan Lance Taylor <ian@airs.com>1994-09-14 20:21:21 +0000
commite4798f4093a02cb1626e808df98bf248b83b0483 (patch)
tree9d3d1a92269c034d1aef7c22dfd4118251cdcc92 /binutils
parent9be909aef7c72401f81b5376ddb715b6b2a399de (diff)
downloadgdb-e4798f4093a02cb1626e808df98bf248b83b0483.zip
gdb-e4798f4093a02cb1626e808df98bf248b83b0483.tar.gz
gdb-e4798f4093a02cb1626e808df98bf248b83b0483.tar.bz2
* 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.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog5
-rw-r--r--binutils/objdump.c15
2 files changed, 15 insertions, 5 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 727c1d8..35cca2c 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,10 @@
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.
(sort_by_size): New static variable.
(long_options): Add --size-sort.
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 7f0c9f9..b158c53 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -451,8 +451,8 @@ disassemble_data (abfd)
struct disassemble_info disasm_info;
struct objdump_disasm_info aux;
- int prevline;
- CONST char *prev_function = "";
+ int prevline = 0;
+ char *prev_function = NULL;
asection *section;
@@ -561,11 +561,16 @@ disassemble_data (abfd)
&functionname,
&line))
{
- if (functionname && *functionname
- && strcmp(functionname, prev_function))
+ if (functionname
+ && *functionname != '\0'
+ && (prev_function == NULL
+ || strcmp (functionname, prev_function) != 0))
{
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)
filename = "???";