mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-26 22:07:58 +08:00
from minyard@bnr.ca: free up copy of section contents each time through loop
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
Mon Feb 22 10:27:24 1993 Ken Raeburn (raeburn@cambridge.cygnus.com)
|
||||||
|
|
||||||
|
* objdump.c (dump_data): Free up section contents each time
|
||||||
|
through the loop. Reported by minyard@bnr.ca.
|
||||||
|
|
||||||
Sun Feb 21 10:55:55 1993 Mike Werner (mtw@poseidon.cygnus.com)
|
Sun Feb 21 10:55:55 1993 Mike Werner (mtw@poseidon.cygnus.com)
|
||||||
|
|
||||||
* binutils/testsuite: Initial creation of binutils/testsuite.
|
* binutils/testsuite: Initial creation of binutils/testsuite.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* objdump.c -- dump information about an object file.
|
/* objdump.c -- dump information about an object file.
|
||||||
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of BFD, the Binary File Diddler.
|
This file is part of BFD, the Binary File Diddler.
|
||||||
|
|
||||||
@ -61,27 +61,28 @@ boolean disassemble; /* -d */
|
|||||||
boolean info; /* -i */
|
boolean info; /* -i */
|
||||||
char *only;
|
char *only;
|
||||||
|
|
||||||
PROTO (void, display_file, (char *filename, char *target));
|
|
||||||
PROTO (void, dump_data, (bfd * abfd));
|
|
||||||
PROTO (void, dump_relocs, (bfd * abfd));
|
|
||||||
PROTO (void, dump_symbols, (bfd * abfd));
|
|
||||||
PROTO (void, print_arelt_descr, (FILE *, bfd * abfd, boolean verbose));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *machine = (char *) NULL;
|
char *machine = (char *) NULL;
|
||||||
asymbol **syms;
|
asymbol **syms;
|
||||||
asymbol **syms2;
|
asymbol **syms2;
|
||||||
|
|
||||||
|
|
||||||
unsigned int storage;
|
unsigned int storage;
|
||||||
|
|
||||||
unsigned int symcount = 0;
|
unsigned int symcount = 0;
|
||||||
|
|
||||||
|
/* Forward declarations. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
display_file PARAMS ((char *filename, char *target));
|
||||||
|
|
||||||
|
static void
|
||||||
|
dump_data PARAMS ((bfd *abfd));
|
||||||
|
|
||||||
|
static void
|
||||||
|
dump_relocs PARAMS ((bfd *abfd));
|
||||||
|
|
||||||
|
static void
|
||||||
|
dump_symbols PARAMS ((bfd *abfd));
|
||||||
|
|
||||||
void
|
void
|
||||||
usage ()
|
usage ()
|
||||||
{
|
{
|
||||||
@ -179,13 +180,18 @@ comp (ap, bp)
|
|||||||
asymbol *a = *(asymbol **)ap;
|
asymbol *a = *(asymbol **)ap;
|
||||||
asymbol *b = *(asymbol **)bp;
|
asymbol *b = *(asymbol **)bp;
|
||||||
int diff;
|
int diff;
|
||||||
|
bfd *a_bfd, *b_bfd;
|
||||||
|
|
||||||
if (a->name == (char *) NULL || (a->flags & (BSF_DEBUGGING)))
|
if (a->name == (char *) NULL || (a->flags & (BSF_DEBUGGING)))
|
||||||
a->the_bfd = 0;
|
a_bfd = 0;
|
||||||
|
else
|
||||||
|
a_bfd = bfd_asymbol_bfd(a);
|
||||||
if (b->name == (char *) NULL || (b->flags & (BSF_DEBUGGING)))
|
if (b->name == (char *) NULL || (b->flags & (BSF_DEBUGGING)))
|
||||||
b->the_bfd = 0;
|
b_bfd = 0;
|
||||||
|
else
|
||||||
|
b_bfd = bfd_asymbol_bfd(b);
|
||||||
|
|
||||||
diff = a->the_bfd - b->the_bfd;
|
diff = a_bfd - b_bfd;
|
||||||
if (diff)
|
if (diff)
|
||||||
{
|
{
|
||||||
return -diff;
|
return -diff;
|
||||||
@ -229,7 +235,11 @@ print_address (vma, stream)
|
|||||||
break;
|
break;
|
||||||
vardiff = syms[thisplace]->value - vma;
|
vardiff = syms[thisplace]->value - vma;
|
||||||
|
|
||||||
if (vardiff)
|
if (vardiff
|
||||||
|
/* Check that the value isn't merely a coincidence.
|
||||||
|
(if not checked, we might print some undefined symbol
|
||||||
|
for the address 0 rather than "main", for example. */
|
||||||
|
|| !(syms[thisplace]->flags & (BSF_GLOBAL|BSF_LOCAL)))
|
||||||
{
|
{
|
||||||
if (vardiff > 0)
|
if (vardiff > 0)
|
||||||
{
|
{
|
||||||
@ -297,10 +307,13 @@ disassemble_data (abfd)
|
|||||||
unsigned int (*print) ()= 0;
|
unsigned int (*print) ()= 0;
|
||||||
unsigned int print_insn_m68k ();
|
unsigned int print_insn_m68k ();
|
||||||
unsigned int print_insn_a29k ();
|
unsigned int print_insn_a29k ();
|
||||||
|
unsigned int print_insn_z8001 ();
|
||||||
|
unsigned int print_insn_z8002 ();
|
||||||
unsigned int print_insn_i960 ();
|
unsigned int print_insn_i960 ();
|
||||||
unsigned int print_insn_sparc ();
|
unsigned int print_insn_sparc ();
|
||||||
unsigned int print_insn_i386 ();
|
unsigned int print_insn_i386 ();
|
||||||
unsigned int print_insn_h8300 ();
|
unsigned int print_insn_h8300 ();
|
||||||
|
unsigned int print_insn_mips ();
|
||||||
enum bfd_architecture a;
|
enum bfd_architecture a;
|
||||||
|
|
||||||
asection *section;
|
asection *section;
|
||||||
@ -325,7 +338,8 @@ disassemble_data (abfd)
|
|||||||
|
|
||||||
for (i = 0; i < symcount; i++)
|
for (i = 0; i < symcount; i++)
|
||||||
{
|
{
|
||||||
if (syms[i]->the_bfd == 0)
|
if (syms[i]->name == (char *) NULL
|
||||||
|
|| (syms[i]->flags & BSF_DEBUGGING) != 0)
|
||||||
{
|
{
|
||||||
symcount = i;
|
symcount = i;
|
||||||
break;
|
break;
|
||||||
@ -361,6 +375,12 @@ disassemble_data (abfd)
|
|||||||
case bfd_arch_sparc:
|
case bfd_arch_sparc:
|
||||||
print = print_insn_sparc;
|
print = print_insn_sparc;
|
||||||
break;
|
break;
|
||||||
|
case bfd_arch_z8k:
|
||||||
|
if (bfd_get_mach(abfd) == bfd_mach_z8001)
|
||||||
|
print = print_insn_z8001;
|
||||||
|
else
|
||||||
|
print = print_insn_z8002;
|
||||||
|
break;
|
||||||
case bfd_arch_i386:
|
case bfd_arch_i386:
|
||||||
print = print_insn_i386;
|
print = print_insn_i386;
|
||||||
break;
|
break;
|
||||||
@ -373,6 +393,10 @@ disassemble_data (abfd)
|
|||||||
case bfd_arch_i960:
|
case bfd_arch_i960:
|
||||||
print = print_insn_i960;
|
print = print_insn_i960;
|
||||||
break;
|
break;
|
||||||
|
case bfd_arch_mips:
|
||||||
|
/* MIPS is handled specially, because we need to pass an
|
||||||
|
additional endianness argument. */
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "%s: Can't disassemble for architecture %s\n",
|
fprintf (stderr, "%s: Can't disassemble for architecture %s\n",
|
||||||
program_name,
|
program_name,
|
||||||
@ -429,15 +453,17 @@ disassemble_data (abfd)
|
|||||||
CONST char *functionname;
|
CONST char *functionname;
|
||||||
unsigned int line;
|
unsigned int line;
|
||||||
|
|
||||||
bfd_find_nearest_line (abfd,
|
if (bfd_find_nearest_line (abfd,
|
||||||
section,
|
section,
|
||||||
syms,
|
syms,
|
||||||
section->vma + i,
|
section->vma + i,
|
||||||
&filename,
|
&filename,
|
||||||
&functionname,
|
&functionname,
|
||||||
&line);
|
&line)
|
||||||
|
&& filename
|
||||||
if (filename && functionname && line && line != prevline)
|
&& functionname
|
||||||
|
&& line
|
||||||
|
&& line != prevline)
|
||||||
{
|
{
|
||||||
printf ("%s:%u\n", filename, line);
|
printf ("%s:%u\n", filename, line);
|
||||||
prevline = line;
|
prevline = line;
|
||||||
@ -446,9 +472,18 @@ disassemble_data (abfd)
|
|||||||
print_address (section->vma + i, stdout);
|
print_address (section->vma + i, stdout);
|
||||||
printf (" ");
|
printf (" ");
|
||||||
|
|
||||||
i += print (section->vma + i,
|
if (a != bfd_arch_mips)
|
||||||
data + i,
|
i += print (section->vma + i,
|
||||||
stdout);
|
data + i,
|
||||||
|
stdout);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The endianness of the MIPS can vary. */
|
||||||
|
i += print_insn_mips (section->vma + i,
|
||||||
|
data + i,
|
||||||
|
stdout,
|
||||||
|
(int) abfd->xvec->byteorder_big_p);
|
||||||
|
}
|
||||||
putchar ('\n');
|
putchar ('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -546,7 +581,7 @@ dump_elf_stabs_1 (abfd, name1, name2)
|
|||||||
strtab = (char *) xmalloc (stabstr_hdr->sh_size);
|
strtab = (char *) xmalloc (stabstr_hdr->sh_size);
|
||||||
stabs_end = (struct internal_nlist *) (stab_hdr->sh_size + (char *)stabs);
|
stabs_end = (struct internal_nlist *) (stab_hdr->sh_size + (char *)stabs);
|
||||||
|
|
||||||
if (bfd_seek (abfd, stab_hdr->sh_offset, L_SET) < 0 ||
|
if (bfd_seek (abfd, stab_hdr->sh_offset, SEEK_SET) < 0 ||
|
||||||
stab_hdr->sh_size != bfd_read ((PTR)stabs, stab_hdr->sh_size, 1, abfd))
|
stab_hdr->sh_size != bfd_read ((PTR)stabs, stab_hdr->sh_size, 1, abfd))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: reading %s section of %s failed.\n",
|
fprintf (stderr, "%s: reading %s section of %s failed.\n",
|
||||||
@ -555,7 +590,7 @@ dump_elf_stabs_1 (abfd, name1, name2)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bfd_seek (abfd, stabstr_hdr->sh_offset, L_SET) < 0 ||
|
if (bfd_seek (abfd, stabstr_hdr->sh_offset, SEEK_SET) < 0 ||
|
||||||
stabstr_hdr->sh_size != bfd_read ((PTR)strtab, stabstr_hdr->sh_size,
|
stabstr_hdr->sh_size != bfd_read ((PTR)strtab, stabstr_hdr->sh_size,
|
||||||
1, abfd))
|
1, abfd))
|
||||||
{
|
{
|
||||||
@ -675,7 +710,7 @@ display_bfd (abfd)
|
|||||||
disassemble_data (abfd);
|
disassemble_data (abfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
display_file (filename, target)
|
display_file (filename, target)
|
||||||
char *filename;
|
char *filename;
|
||||||
char *target;
|
char *target;
|
||||||
@ -716,7 +751,7 @@ display_file (filename, target)
|
|||||||
|
|
||||||
/* Actually display the various requested regions */
|
/* Actually display the various requested regions */
|
||||||
|
|
||||||
void
|
static void
|
||||||
dump_data (abfd)
|
dump_data (abfd)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
{
|
{
|
||||||
@ -775,14 +810,14 @@ dump_data (abfd)
|
|||||||
}
|
}
|
||||||
putchar ('\n');
|
putchar ('\n');
|
||||||
}
|
}
|
||||||
|
free (data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free (data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Should perhaps share code and display with nm? */
|
/* Should perhaps share code and display with nm? */
|
||||||
void
|
static void
|
||||||
dump_symbols (abfd)
|
dump_symbols (abfd)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
{
|
{
|
||||||
@ -795,13 +830,16 @@ dump_symbols (abfd)
|
|||||||
for (count = 0; count < symcount; count++)
|
for (count = 0; count < symcount; count++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (*current && (*current)->the_bfd)
|
if (*current)
|
||||||
{
|
{
|
||||||
bfd_print_symbol ((*current)->the_bfd,
|
bfd *cur_bfd = bfd_asymbol_bfd(*current);
|
||||||
stdout,
|
if (cur_bfd)
|
||||||
*current, bfd_print_symbol_all);
|
{
|
||||||
|
bfd_print_symbol (cur_bfd,
|
||||||
printf ("\n");
|
stdout,
|
||||||
|
*current, bfd_print_symbol_all);
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
current++;
|
current++;
|
||||||
@ -810,7 +848,7 @@ dump_symbols (abfd)
|
|||||||
printf ("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
dump_relocs (abfd)
|
dump_relocs (abfd)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
{
|
{
|
||||||
@ -824,7 +862,7 @@ dump_relocs (abfd)
|
|||||||
continue;
|
continue;
|
||||||
if (a == &bfd_und_section)
|
if (a == &bfd_und_section)
|
||||||
continue;
|
continue;
|
||||||
if (a == &bfd_com_section)
|
if (bfd_is_com_section (a))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
printf ("RELOCATION RECORDS FOR [%s]:", a->name);
|
printf ("RELOCATION RECORDS FOR [%s]:", a->name);
|
||||||
|
Reference in New Issue
Block a user