/* readelf.c -- display contents of an ELF format file
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008, 2009, 2010
+ 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Originally developed by Eric Youngdale <eric@andante.jic.com>
Returns the number of emitted characters. */
static unsigned int
-print_symbol (int width, const char * symbol)
+print_symbol (int width, const char *symbol)
{
- const char * c;
+ const char *c;
bfd_boolean extra_padding = FALSE;
unsigned int num_printed = 0;
if (do_wide)
{
- /* Set the width to a very large value. This simplifies the code below. */
+ /* Set the width to a very large value. This simplifies the
+ code below. */
width = INT_MAX;
}
else if (width < 0)
/* Look for non-printing symbols inside the symbol's name.
This test is triggered in particular by the names generated
by the assembler for local labels. */
- while (ISPRINT (* c))
+ while (ISPRINT (*c))
c++;
len = c - symbol;
num_printed += len;
}
- if (* c == 0 || width == 0)
+ if (*c == 0 || width == 0)
break;
/* Now display the non-printing character, if
there is room left in which to dipslay it. */
- if (*c < 32)
+ if ((unsigned char) *c < 32)
{
if (width < 2)
break;
if (width < 6)
break;
- printf ("<0x%.2x>", *c);
+ printf ("<0x%.2x>", (unsigned char) *c);
width -= 6;
num_printed += 6;
if (elf_header.e_phnum == 0)
{
- if (do_segments)
+ /* PR binutils/12467. */
+ if (elf_header.e_phoff != 0)
+ warn (_("possibly corrupt ELF header - it has a non-zero program"
+ " header offset, but no program headers"));
+ else if (do_segments)
printf (_("\nThere are no program headers in this file.\n"));
return 0;
}
if (elf_header.e_shnum == 0)
{
- if (do_sections)
+ /* PR binutils/12467. */
+ if (elf_header.e_shoff != 0)
+ warn (_("possibly corrupt ELF file header - it has a non-zero"
+ " section header offset, but no section headers\n"));
+ else if (do_sections)
printf (_("\nThere are no sections in this file.\n"));
return 1;
if (elf_header.e_shnum == 0)
{
if (do_section_groups)
- printf (_("\nThere are no sections in this file.\n"));
+ printf (_("\nThere are no sections to group in this file.\n"));
return 1;
}
dynamic_syminfo = NULL;
}
+ if (dynamic_section)
+ {
+ free (dynamic_section);
+ dynamic_section = NULL;
+ }
+
if (section_headers_groups)
{
free (section_headers_groups);
ret |= process_object (qualified_name, file);
}
+ if (dump_sects != NULL)
+ {
+ free (dump_sects);
+ dump_sects = NULL;
+ num_dump_sects = 0;
+ }
+
free (qualified_name);
}