/* readelf.c -- display contents of an ELF format file
- Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Originally developed by Eric Youngdale <eric@andante.jic.com>
Modifications by Nick Clifton <nickc@redhat.com>
Both programs are capabale of displaying the contents of ELF format files,
so why does the binutils project have two file dumpers ?
-
+
The reason is that objdump sees an ELF file through a BFD filter of the
world; if BFD has a bug where, say, it disagrees about a machine constant
in e_flags, then the odds are good that it will remain internally
#include "elf/vax.h"
#include "elf/x86-64.h"
#include "elf/xstormy16.h"
+#include "elf/crx.h"
#include "elf/iq2000.h"
#include "elf/xtensa.h"
unsigned long archive_file_size;
unsigned long dynamic_addr;
bfd_size_type dynamic_size;
+unsigned int dynamic_nent;
char *dynamic_strings;
char *string_table;
unsigned long string_table_length;
Elf_Internal_Ehdr elf_header;
Elf_Internal_Shdr *section_headers;
Elf_Internal_Phdr *program_headers;
-Elf_Internal_Dyn *dynamic_segment;
+Elf_Internal_Dyn *dynamic_section;
Elf_Internal_Shdr *symtab_shndx_hdr;
int show_name;
int do_dynamic;
int do_syms;
int do_reloc;
int do_sections;
+int do_section_groups;
int do_segments;
int do_unwind;
int do_using_dynamic;
int do_notes;
int is_32bit_elf;
+struct group_list
+{
+ struct group_list *next;
+ unsigned int section_index;
+};
+
+struct group
+{
+ struct group_list *root;
+ unsigned int group_index;
+};
+
+struct group *section_groups;
+size_t group_count = 0;
+
+struct group **section_headers_groups;
+
/* A dynamic array of flags indicating which sections require dumping. */
char *dump_sects = NULL;
unsigned int num_dump_sects = 0;
static bfd_vma (*byte_get) (unsigned char *, int);
static void (*byte_put) (unsigned char *, bfd_vma, int);
-typedef int Elf32_Word;
-
#define UNKNOWN -1
#define SECTION_NAME(X) ((X) == NULL ? "<none>" : \
case EM_MSP430:
case EM_MSP430_OLD:
case EM_XSTORMY16:
+ case EM_CRX:
case EM_VAX:
case EM_IP2K:
case EM_IP2K_OLD:
rtype = elf_i386_reloc_type (type);
break;
- case EM_68HC11:
- case EM_68HC12:
- rtype = elf_m68hc11_reloc_type (type);
- break;
+ case EM_68HC11:
+ case EM_68HC12:
+ rtype = elf_m68hc11_reloc_type (type);
+ break;
case EM_68K:
rtype = elf_m68k_reloc_type (type);
rtype = elf_fr30_reloc_type (type);
break;
- case EM_CYGNUS_FRV:
- rtype = elf_frv_reloc_type (type);
- break;
+ case EM_CYGNUS_FRV:
+ rtype = elf_frv_reloc_type (type);
+ break;
case EM_MCORE:
rtype = elf_mcore_reloc_type (type);
rtype = elf_xstormy16_reloc_type (type);
break;
+ case EM_CRX:
+ rtype = elf_crx_reloc_type (type);
+ break;
+
case EM_VAX:
rtype = elf_vax_reloc_type (type);
break;
if (psym->st_shndx < SHN_LORESERVE)
sec_index = psym->st_shndx;
- else if (psym->st_shndx > SHN_LORESERVE)
+ else if (psym->st_shndx > SHN_HIRESERVE)
sec_index = psym->st_shndx - (SHN_HIRESERVE + 1
- SHN_LORESERVE);
{
case ET_NONE: return _("NONE (None)");
case ET_REL: return _("REL (Relocatable file)");
- case ET_EXEC: return _("EXEC (Executable file)");
- case ET_DYN: return _("DYN (Shared object file)");
- case ET_CORE: return _("CORE (Core file)");
+ case ET_EXEC: return _("EXEC (Executable file)");
+ case ET_DYN: return _("DYN (Shared object file)");
+ case ET_CORE: return _("CORE (Core file)");
default:
if ((e_type >= ET_LOPROC) && (e_type <= ET_HIPROC))
case EM_XSTORMY16: return "Sanyo Xstormy16 CPU core";
case EM_OPENRISC:
case EM_OR32: return "OpenRISC";
+ case EM_CRX: return "National Semiconductor CRX microprocessor";
case EM_DLX: return "OpenDLX";
case EM_IP2K_OLD:
case EM_IP2K: return "Ubicom IP2xxx 8-bit microcontrollers";
}
break;
+ case EF_ARM_EABI_VER3:
+ strcat (buf, ", Version3 EABI");
+ while (e_flags)
+ {
+ unsigned flag;
+
+ /* Process flags one bit at a time. */
+ flag = e_flags & - e_flags;
+ e_flags &= ~ flag;
+
+ switch (flag)
+ {
+ case EF_ARM_BE8:
+ strcat (buf, ", BE8");
+ break;
+
+ case EF_ARM_LE8:
+ strcat (buf, ", LE8");
+ break;
+
+ default:
+ unknown = 1;
+ break;
+ }
+ }
+ break;
+
case EF_ARM_EABI_UNKNOWN:
strcat (buf, ", GNU EABI");
while (e_flags)
strcat (buf, ", software FP");
break;
+ case EF_ARM_VFP_FLOAT:
+ strcat (buf, ", VFP");
+ break;
+
case EF_ARM_MAVERICK_FLOAT:
strcat (buf, ", Maverick FP");
break;
break;
+ case EM_SH:
+ switch ((e_flags & EF_SH_MACH_MASK))
+ {
+ case EF_SH1: strcat (buf, ", sh1"); break;
+ case EF_SH2: strcat (buf, ", sh2"); break;
+ case EF_SH3: strcat (buf, ", sh3"); break;
+ case EF_SH_DSP: strcat (buf, ", sh-dsp"); break;
+ case EF_SH3_DSP: strcat (buf, ", sh3-dsp"); break;
+ case EF_SH4AL_DSP: strcat (buf, ", sh4al-dsp"); break;
+ case EF_SH3E: strcat (buf, ", sh3e"); break;
+ case EF_SH4: strcat (buf, ", sh4"); break;
+ case EF_SH5: strcat (buf, ", sh5"); break;
+ case EF_SH2E: strcat (buf, ", sh2e"); break;
+ case EF_SH4A: strcat (buf, ", sh4a"); break;
+ case EF_SH2A: strcat (buf, ", sh2a"); break;
+ case EF_SH4_NOFPU: strcat (buf, ", sh4-nofpu"); break;
+ case EF_SH4A_NOFPU: strcat (buf, ", sh4a-nofpu"); break;
+ case EF_SH2A_NOFPU: strcat (buf, ", sh2a-nofpu"); break;
+ default: strcat (buf, ", unknown ISA"); break;
+ }
+
+ break;
+
case EM_SPARCV9:
if (e_flags & EF_SPARC_32PLUS)
strcat (buf, ", v8+");
case PT_GNU_EH_FRAME:
return "GNU_EH_FRAME";
- case PT_GNU_STACK: return "STACK";
+ case PT_GNU_STACK: return "GNU_STACK";
+ case PT_GNU_RELRO: return "GNU_RELRO";
default:
if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC))
/* If the top 8 bits are 0x78 the next 8 are the os/abi ID. */
if ((sh_type & 0xFF000000) == SHT_IA_64_LOPSREG)
return get_osabi_name ((sh_type & 0x00FF0000) >> 16);
-
+
switch (sh_type)
{
case SHT_IA_64_EXT: return "IA_64_EXT";
{"segments", no_argument, 0, 'l'},
{"sections", no_argument, 0, 'S'},
{"section-headers", no_argument, 0, 'S'},
+ {"section-groups", no_argument, 0, 'g'},
{"symbols", no_argument, 0, 's'},
{"syms", no_argument, 0, 's'},
{"relocs", no_argument, 0, 'r'},
--segments An alias for --program-headers\n\
-S --section-headers Display the sections' header\n\
--sections An alias for --section-headers\n\
+ -g --section-groups Display the section groups\n\
-e --headers Equivalent to: -h -l -S\n\
-s --syms Display the symbol table\n\
--symbols An alias for --syms\n\
-n --notes Display the core notes (if present)\n\
-r --relocs Display the relocations (if present)\n\
-u --unwind Display the unwind info (if present)\n\
- -d --dynamic Display the dynamic segment (if present)\n\
+ -d --dynamic Display the dynamic section (if present)\n\
-V --version-info Display the version sections (if present)\n\
-A --arch-specific Display architecture specific information (if any).\n\
-D --use-dynamic Use the dynamic section info when displaying symbols\n\
usage ();
while ((c = getopt_long
- (argc, argv, "ersuahnldSDAIw::x:i:vVWH", options, NULL)) != EOF)
+ (argc, argv, "ersuahnldSDAIgw::x:i:vVWH", options, NULL)) != EOF)
{
char *cp;
int section;
do_dynamic++;
do_header++;
do_sections++;
+ do_section_groups++;
do_segments++;
do_version++;
do_histogram++;
do_arch++;
do_notes++;
break;
+ case 'g':
+ do_section_groups++;
+ break;
case 'e':
do_header++;
do_sections++;
if (!do_dynamic && !do_syms && !do_reloc && !do_unwind && !do_sections
&& !do_segments && !do_header && !do_dump && !do_version
- && !do_histogram && !do_debugging && !do_arch && !do_notes)
+ && !do_histogram && !do_debugging && !do_arch && !do_notes
+ && !do_section_groups)
usage ();
else if (argc < 3)
{
if (dynamic_addr)
error (_("more than one dynamic segment\n"));
- dynamic_addr = segment->p_offset;
- dynamic_size = segment->p_filesz;
+ /* Try to locate the .dynamic section. If there is
+ a section header table, we can easily locate it. */
+ if (section_headers != NULL)
+ {
+ Elf_Internal_Shdr *sec;
+ unsigned int j;
+
+ for (j = 0, sec = section_headers;
+ j < elf_header.e_shnum;
+ j++, sec++)
+ if (strcmp (SECTION_NAME (sec), ".dynamic") == 0)
+ break;
+
+ if (j == elf_header.e_shnum || sec->sh_size == 0)
+ {
+ error (_("no .dynamic section in the dynamic segment"));
+ break;
+ }
+
+ dynamic_addr = sec->sh_offset;
+ dynamic_size = sec->sh_size;
+
+ if (dynamic_addr < segment->p_offset
+ || dynamic_addr > segment->p_offset + segment->p_filesz)
+ warn (_("the .dynamic section is not contained within the dynamic segment"));
+ else if (dynamic_addr > segment->p_offset)
+ warn (_("the .dynamic section is not the first section in the dynamic segment."));
+ }
+ else
+ {
+ /* Otherwise, we can only assume that the .dynamic
+ section is the first section in the DYNAMIC segment. */
+ dynamic_addr = segment->p_offset;
+ dynamic_size = segment->p_filesz;
+ }
break;
case PT_INTERP:
if (string_table == NULL)
return 0;
-
+
string_table_length = section->sh_size;
}
printf (" %3s ", get_elf_section_flags (section->sh_flags));
- printf ("%2ld %3lx %2ld\n",
+ printf ("%2ld %3lu %2ld\n",
(unsigned long) section->sh_link,
(unsigned long) section->sh_info,
(unsigned long) section->sh_addralign);
printf (" %3s ", get_elf_section_flags (section->sh_flags));
- printf ("%2ld %3lx ",
+ printf ("%2ld %3lu ",
(unsigned long) section->sh_link,
(unsigned long) section->sh_info);
printf (" %3s ", get_elf_section_flags (section->sh_flags));
- printf (" %2ld %3lx %ld\n",
+ printf (" %2ld %3lu %ld\n",
(unsigned long) section->sh_link,
(unsigned long) section->sh_info,
(unsigned long) section->sh_addralign);
return 1;
}
+static const char *
+get_group_flags (unsigned int flags)
+{
+ static char buff[32];
+ switch (flags)
+ {
+ case GRP_COMDAT:
+ return "COMDAT";
+
+ default:
+ sprintf (buff, _("[<unknown>: 0x%x]"), flags);
+ break;
+ }
+ return buff;
+}
+
+static int
+process_section_groups (FILE *file)
+{
+ Elf_Internal_Shdr *section;
+ unsigned int i;
+ struct group *group;
+
+ if (elf_header.e_shnum == 0)
+ {
+ if (do_section_groups)
+ printf (_("\nThere are no section groups in this file.\n"));
+
+ return 1;
+ }
+
+ if (section_headers == NULL)
+ {
+ error (_("Section headers are not available!\n"));
+ abort ();
+ }
+
+ section_headers_groups = calloc (elf_header.e_shnum,
+ sizeof (struct group *));
+
+ if (section_headers_groups == NULL)
+ {
+ error (_("Out of memory\n"));
+ return 0;
+ }
+
+ /* Scan the sections for the group section. */
+ for (i = 0, section = section_headers;
+ i < elf_header.e_shnum;
+ i++, section++)
+ if (section->sh_type == SHT_GROUP)
+ group_count++;
+
+ section_groups = calloc (group_count, sizeof (struct group));
+
+ if (section_groups == NULL)
+ {
+ error (_("Out of memory\n"));
+ return 0;
+ }
+
+ for (i = 0, section = section_headers, group = section_groups;
+ i < elf_header.e_shnum;
+ i++, section++)
+ {
+ if (section->sh_type == SHT_GROUP)
+ {
+ char *name = SECTION_NAME (section);
+ char *group_name, *strtab, *start, *indices;
+ unsigned int entry, j, size;
+ Elf_Internal_Sym *sym;
+ Elf_Internal_Shdr *symtab_sec, *strtab_sec, *sec;
+ Elf_Internal_Sym *symtab;
+
+ /* Get the symbol table. */
+ symtab_sec = SECTION_HEADER (section->sh_link);
+ if (symtab_sec->sh_type != SHT_SYMTAB)
+ {
+ error (_("Bad sh_link in group section `%s'\n"), name);
+ continue;
+ }
+ symtab = GET_ELF_SYMBOLS (file, symtab_sec);
+
+ sym = symtab + section->sh_info;
+
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ bfd_vma sec_index = SECTION_HEADER_INDEX (sym->st_shndx);
+ if (sec_index == 0)
+ {
+ error (_("Bad sh_info in group section `%s'\n"), name);
+ continue;
+ }
+
+ group_name = SECTION_NAME (section_headers + sec_index);
+ strtab = NULL;
+ }
+ else
+ {
+ /* Get the string table. */
+ strtab_sec = SECTION_HEADER (symtab_sec->sh_link);
+ strtab = get_data (NULL, file, strtab_sec->sh_offset,
+ strtab_sec->sh_size,
+ _("string table"));
+
+ group_name = strtab + sym->st_name;
+ }
+
+ start = get_data (NULL, file, section->sh_offset,
+ section->sh_size, _("section data"));
+
+ indices = start;
+ size = (section->sh_size / section->sh_entsize) - 1;
+ entry = byte_get (indices, 4);
+ indices += 4;
+
+ if (do_section_groups)
+ {
+ printf ("\n%s group section `%s' [%s] contains %u sections:\n",
+ get_group_flags (entry), name, group_name, size);
+
+ printf (_(" [Index] Name\n"));
+ }
+
+ group->group_index = i;
+
+ for (j = 0; j < size; j++)
+ {
+ struct group_list *g;
+
+ entry = byte_get (indices, 4);
+ indices += 4;
+
+ if (section_headers_groups [SECTION_HEADER_INDEX (entry)]
+ != NULL)
+ {
+ error (_("section [%5u] already in group section [%5u]\n"),
+ entry, section_headers_groups [SECTION_HEADER_INDEX (entry)]->group_index);
+ continue;
+ }
+
+ section_headers_groups [SECTION_HEADER_INDEX (entry)]
+ = group;
+
+ if (do_section_groups)
+ {
+ sec = SECTION_HEADER (entry);
+ printf (" [%5u] %s\n",
+ entry, SECTION_NAME (sec));
+ }
+
+ g = xmalloc (sizeof (struct group_list));
+ g->section_index = entry;
+ g->next = group->root;
+ group->root = g;
+ }
+
+ if (strtab)
+ free (strtab);
+ if (start)
+ free (start);
+
+ group++;
+ }
+ }
+
+ return 1;
+}
+
struct
{
const char *name;
const char *name;
int has_dynamic_reloc;
unsigned int i;
-
+
has_dynamic_reloc = 0;
for (i = 0; i < ARRAY_SIZE (dynamic_relocations); i++)
unwstart = i + 1;
len = sizeof (ELF_STRING_ia64_unwind_once) - 1;
- if (strncmp (SECTION_NAME (unwsec), ELF_STRING_ia64_unwind_once,
- len) == 0)
+ if ((unwsec->sh_flags & SHF_GROUP) != 0)
+ {
+ /* We need to find which section group it is in. */
+ struct group_list *g = section_headers_groups [i]->root;
+
+ for (; g != NULL; g = g->next)
+ {
+ sec = SECTION_HEADER (g->section_index);
+ if (strcmp (SECTION_NAME (sec),
+ ELF_STRING_ia64_unwind_info) == 0)
+ break;
+ }
+
+ if (g == NULL)
+ i = elf_header.e_shnum;
+ }
+ else if (strncmp (SECTION_NAME (unwsec),
+ ELF_STRING_ia64_unwind_once, len) == 0)
{
/* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.ia64unwi.FOO */
len2 = sizeof (ELF_STRING_ia64_unwind_info_once) - 1;
}
static void
-dynamic_segment_mips_val (Elf_Internal_Dyn *entry)
+dynamic_section_mips_val (Elf_Internal_Dyn *entry)
{
switch (entry->d_tag)
{
static void
-dynamic_segment_parisc_val (Elf_Internal_Dyn *entry)
+dynamic_section_parisc_val (Elf_Internal_Dyn *entry)
{
switch (entry->d_tag)
{
}
static void
-dynamic_segment_ia64_val (Elf_Internal_Dyn *entry)
+dynamic_section_ia64_val (Elf_Internal_Dyn *entry)
{
switch (entry->d_tag)
{
- case DT_IA_64_PLT_RESERVE:
+ case DT_IA_64_PLT_RESERVE:
/* First 3 slots reserved. */
print_vma (entry->d_un.d_ptr, PREFIX_HEX);
printf (" -- ");
}
static int
-get_32bit_dynamic_segment (FILE *file)
+get_32bit_dynamic_section (FILE *file)
{
- Elf32_External_Dyn *edyn;
+ Elf32_External_Dyn *edyn, *ext;
Elf_Internal_Dyn *entry;
- bfd_size_type i;
edyn = get_data (NULL, file, dynamic_addr, dynamic_size,
- _("dynamic segment"));
+ _("dynamic section"));
if (!edyn)
return 0;
- /* SGI's ELF has more than one section in the DYNAMIC segment. Determine
- how large this .dynamic is now. We can do this even before the byte
- swapping since the DT_NULL tag is recognizable. */
- dynamic_size = 0;
- while (*(Elf32_Word *) edyn[dynamic_size++].d_tag != DT_NULL)
- ;
-
- dynamic_segment = malloc (dynamic_size * sizeof (Elf_Internal_Dyn));
+/* SGI's ELF has more than one section in the DYNAMIC segment, and we
+ might not have the luxury of section headers. Look for the DT_NULL
+ terminator to determine the number of entries. */
+ for (ext = edyn, dynamic_nent = 0;
+ (char *) ext < (char *) edyn + dynamic_size;
+ ext++)
+ {
+ dynamic_nent++;
+ if (BYTE_GET (ext->d_tag) == DT_NULL)
+ break;
+ }
- if (dynamic_segment == NULL)
+ dynamic_section = malloc (dynamic_nent * sizeof (*entry));
+ if (dynamic_section == NULL)
{
error (_("Out of memory\n"));
free (edyn);
return 0;
}
- for (i = 0, entry = dynamic_segment;
- i < dynamic_size;
- i++, entry++)
+ for (ext = edyn, entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ ext++, entry++)
{
- entry->d_tag = BYTE_GET (edyn[i].d_tag);
- entry->d_un.d_val = BYTE_GET (edyn[i].d_un.d_val);
+ entry->d_tag = BYTE_GET (ext->d_tag);
+ entry->d_un.d_val = BYTE_GET (ext->d_un.d_val);
}
free (edyn);
}
static int
-get_64bit_dynamic_segment (FILE *file)
+get_64bit_dynamic_section (FILE *file)
{
- Elf64_External_Dyn *edyn;
+ Elf64_External_Dyn *edyn, *ext;
Elf_Internal_Dyn *entry;
- bfd_size_type i;
edyn = get_data (NULL, file, dynamic_addr, dynamic_size,
- _("dynamic segment"));
+ _("dynamic section"));
if (!edyn)
return 0;
- /* SGI's ELF has more than one section in the DYNAMIC segment. Determine
- how large this .dynamic is now. We can do this even before the byte
- swapping since the DT_NULL tag is recognizable. */
- dynamic_size = 0;
- while (*(bfd_vma *) edyn[dynamic_size++].d_tag != DT_NULL)
- ;
-
- dynamic_segment = malloc (dynamic_size * sizeof (Elf_Internal_Dyn));
+/* SGI's ELF has more than one section in the DYNAMIC segment, and we
+ might not have the luxury of section headers. Look for the DT_NULL
+ terminator to determine the number of entries. */
+ for (ext = edyn, dynamic_nent = 0;
+ (char *) ext < (char *) edyn + dynamic_size;
+ ext++)
+ {
+ dynamic_nent++;
+ if (BYTE_GET8 (ext->d_tag) == DT_NULL)
+ break;
+ }
- if (dynamic_segment == NULL)
+ dynamic_section = malloc (dynamic_nent * sizeof (*entry));
+ if (dynamic_section == NULL)
{
error (_("Out of memory\n"));
free (edyn);
return 0;
}
- for (i = 0, entry = dynamic_segment;
- i < dynamic_size;
- i++, entry++)
+ for (ext = edyn, entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ ext++, entry++)
{
- entry->d_tag = BYTE_GET8 (edyn[i].d_tag);
- entry->d_un.d_val = BYTE_GET8 (edyn[i].d_un.d_val);
+ entry->d_tag = BYTE_GET8 (ext->d_tag);
+ entry->d_un.d_val = BYTE_GET8 (ext->d_un.d_val);
}
free (edyn);
return buff;
}
-/* Parse and display the contents of the dynamic segment. */
+/* Parse and display the contents of the dynamic section. */
+
static int
-process_dynamic_segment (FILE *file)
+process_dynamic_section (FILE *file)
{
Elf_Internal_Dyn *entry;
- bfd_size_type i;
if (dynamic_size == 0)
{
if (do_dynamic)
- printf (_("\nThere is no dynamic segment in this file.\n"));
+ printf (_("\nThere is no dynamic section in this file.\n"));
return 1;
}
if (is_32bit_elf)
{
- if (! get_32bit_dynamic_segment (file))
+ if (! get_32bit_dynamic_section (file))
return 0;
}
- else if (! get_64bit_dynamic_segment (file))
+ else if (! get_64bit_dynamic_section (file))
return 0;
/* Find the appropriate symbol table. */
if (dynamic_symbols == NULL)
{
- for (i = 0, entry = dynamic_segment;
- i < dynamic_size;
- ++i, ++entry)
+ for (entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ ++entry)
{
Elf_Internal_Shdr section;
/* Similarly find a string table. */
if (dynamic_strings == NULL)
{
- for (i = 0, entry = dynamic_segment;
- i < dynamic_size;
- ++i, ++entry)
+ for (entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ ++entry)
{
unsigned long offset;
long str_tab_len;
{
unsigned long syminsz = 0;
- for (i = 0, entry = dynamic_segment;
- i < dynamic_size;
- ++i, ++entry)
+ for (entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ ++entry)
{
if (entry->d_tag == DT_SYMINENT)
{
if (dynamic_syminfo_offset != 0 && syminsz != 0)
{
- Elf_External_Syminfo *extsyminfo;
+ Elf_External_Syminfo *extsyminfo, *extsym;
Elf_Internal_Syminfo *syminfo;
/* There is a syminfo section. Read the data. */
}
dynamic_syminfo_nent = syminsz / sizeof (Elf_External_Syminfo);
- for (i = 0, syminfo = dynamic_syminfo; i < dynamic_syminfo_nent;
- ++i, ++syminfo)
+ for (syminfo = dynamic_syminfo, extsym = extsyminfo;
+ syminfo < dynamic_syminfo + dynamic_syminfo_nent;
+ ++syminfo, ++extsym)
{
- syminfo->si_boundto = BYTE_GET (extsyminfo[i].si_boundto);
- syminfo->si_flags = BYTE_GET (extsyminfo[i].si_flags);
+ syminfo->si_boundto = BYTE_GET (extsym->si_boundto);
+ syminfo->si_flags = BYTE_GET (extsym->si_flags);
}
free (extsyminfo);
}
if (do_dynamic && dynamic_addr)
- printf (_("\nDynamic segment at offset 0x%lx contains %ld entries:\n"),
- dynamic_addr, (long) dynamic_size);
+ printf (_("\nDynamic section at offset 0x%lx contains %u entries:\n"),
+ dynamic_addr, dynamic_nent);
if (do_dynamic)
printf (_(" Tag Type Name/Value\n"));
- for (i = 0, entry = dynamic_segment;
- i < dynamic_size;
- i++, entry++)
+ for (entry = dynamic_section;
+ entry < dynamic_section + dynamic_nent;
+ entry++)
{
if (do_dynamic)
{
{
case EM_MIPS:
case EM_MIPS_RS3_LE:
- dynamic_segment_mips_val (entry);
+ dynamic_section_mips_val (entry);
break;
case EM_PARISC:
- dynamic_segment_parisc_val (entry);
+ dynamic_section_parisc_val (entry);
break;
case EM_IA_64:
- dynamic_segment_ia64_val (entry);
+ dynamic_section_ia64_val (entry);
break;
default:
print_vma (entry->d_un.d_val, PREFIX_HEX);
break;
default:
if (dynamic_syminfo[i].si_boundto > 0
- && dynamic_syminfo[i].si_boundto < dynamic_size)
+ && dynamic_syminfo[i].si_boundto < dynamic_nent)
{
print_symbol (10,
dynamic_strings
- + (dynamic_segment
+ + (dynamic_section
[dynamic_syminfo[i].si_boundto].d_un.d_val));
putchar (' ' );
}
return len;
}
+/* Finds section NAME inside FILE and returns a
+ pointer to it, or NULL upon failure. */
+
+static Elf_Internal_Shdr *
+find_section (const char * name)
+{
+ Elf_Internal_Shdr *sec;
+ unsigned int i;
+
+ for (i = elf_header.e_shnum, sec = section_headers + i - 1;
+ i; --i, --sec)
+ if (strcmp (SECTION_NAME (sec), name) == 0)
+ break;
+
+ if (i && sec && sec->sh_size != 0)
+ return sec;
+
+ return NULL;
+}
+
/* Size of pointers in the .debug_line section. This information is not
really present in that section. It's obtained before dumping the debug
sections by doing some pre-scan of the .debug_info section. */
-static int debug_line_pointer_size = 4;
+static unsigned int * debug_line_pointer_sizes = NULL;
+static unsigned int num_debug_line_pointer_sizes = 0;
+
+/* Locate and scan the .debug_info section in the file and record the pointer
+ sizes for the compilation units in it. Usually an executable will have
+ just one pointer size, but this is not guaranteed, and so we try not to
+ make any assumptions. Returns zero upon failure, or the number of
+ compilation units upon success. */
+
+static unsigned int
+get_debug_line_pointer_sizes (FILE * file)
+{
+ Elf_Internal_Shdr * section;
+ unsigned char * start;
+ unsigned char * end;
+ unsigned char * begin;
+ unsigned long length;
+ unsigned int num_units;
+ unsigned int unit;
+
+ section = find_section (".debug_info");
+ if (section == NULL)
+ return 0;
+
+ length = section->sh_size;
+ start = get_data (NULL, file, section->sh_offset, section->sh_size,
+ _("extracting pointer sizes from .debug_info section"));
+ if (start == NULL)
+ return 0;
+
+ end = start + section->sh_size;
+ /* First scan the section to get the number of comp units. */
+ for (begin = start, num_units = 0; begin < end; num_units++)
+ {
+ /* Read the first 4 bytes. For a 32-bit DWARF section, this will
+ be the length. For a 64-bit DWARF section, it'll be the escape
+ code 0xffffffff followed by an 8 byte length. */
+ length = byte_get (begin, 4);
+
+ if (length == 0xffffffff)
+ {
+ length = byte_get (begin + 4, 8);
+ begin += length + 12;
+ }
+ else
+ begin += length + 4;
+ }
+
+ if (num_units == 0)
+ {
+ error (_("No comp units in .debug_info section ?"));
+ free (start);
+ return 0;
+ }
+
+ /* Then allocate an array to hold the pointer sizes. */
+ debug_line_pointer_sizes = malloc (num_units * sizeof * debug_line_pointer_sizes);
+ if (debug_line_pointer_sizes == NULL)
+ {
+ error (_("Not enough memory for a pointer size array of %u entries"),
+ num_units);
+ free (start);
+ return 0;
+ }
+
+ /* Populate the array. */
+ for (begin = start, unit = 0; begin < end; unit++)
+ {
+ length = byte_get (begin, 4);
+ if (length == 0xffffffff)
+ {
+ /* For 64-bit DWARF, the 1-byte address_size field is 22 bytes
+ from the start of the section. This is computed as follows:
+
+ unit_length: 12 bytes
+ version: 2 bytes
+ debug_abbrev_offset: 8 bytes
+ -----------------------------
+ Total: 22 bytes */
+
+ debug_line_pointer_sizes [unit] = byte_get (begin + 22, 1);
+ length = byte_get (begin + 4, 8);
+ begin += length + 12;
+ }
+ else
+ {
+ /* For 32-bit DWARF, the 1-byte address_size field is 10 bytes from
+ the start of the section:
+
+ unit_length: 4 bytes
+ version: 2 bytes
+ debug_abbrev_offset: 4 bytes
+ -----------------------------
+ Total: 10 bytes */
+
+ debug_line_pointer_sizes [unit] = byte_get (begin + 10, 1);
+ begin += length + 4;
+ }
+ }
+
+ free (start);
+ num_debug_line_pointer_sizes = num_units;
+ return num_units;
+}
static int
display_debug_lines (Elf_Internal_Shdr *section,
- unsigned char * start,
- FILE *file ATTRIBUTE_UNUSED)
+ unsigned char *start, FILE *file)
{
unsigned char *hdrptr;
DWARF2_Internal_LineInfo info;
int i;
int offset_size;
int initial_length_size;
+ unsigned int comp_unit = 0;
printf (_("\nDump of debug contents of section %s:\n\n"),
SECTION_NAME (section));
+ if (num_debug_line_pointer_sizes == 0)
+ get_debug_line_pointer_sizes (file);
+
while (data < end)
{
+ unsigned int pointer_size;
+
hdrptr = data;
/* Check the length of the block. */
info.li_line_base <<= 24;
info.li_line_base >>= 24;
+ /* Get the pointer size from the comp unit associated
+ with this block of line number information. */
+ if (comp_unit >= num_debug_line_pointer_sizes)
+ {
+ error (_("Not enough comp units for .debug_lines section\n"));
+ return 0;
+ }
+ else
+ {
+ pointer_size = debug_line_pointer_sizes [comp_unit];
+ comp_unit ++;
+ }
+
printf (_(" Length: %ld\n"), info.li_length);
printf (_(" DWARF Version: %d\n"), info.li_version);
printf (_(" Prologue Length: %d\n"), info.li_prologue_length);
printf (_(" Line Base: %d\n"), info.li_line_base);
printf (_(" Line Range: %d\n"), info.li_line_range);
printf (_(" Opcode Base: %d\n"), info.li_opcode_base);
+ printf (_(" (Pointer size: %u)\n"), pointer_size);
end_of_sequence = data + info.li_length + initial_length_size;
{
case DW_LNS_extended_op:
data += process_extended_line_op (data, info.li_default_is_stmt,
- debug_line_pointer_size);
+ pointer_size);
break;
case DW_LNS_copy:
if (offset != 0)
{
data += offset_size;
- printf (" %ld\t\t%s\n", offset, data);
+ printf (" %-6ld\t\t%s\n", offset, data);
data += strlen ((char *) data) + 1;
}
}
case DW_TAG_partial_unit: return "DW_TAG_partial_unit";
case DW_TAG_imported_unit: return "DW_TAG_imported_unit";
/* UPC values. */
- case DW_TAG_upc_shared_type: return "DW_TAG_upc_shared_type";
- case DW_TAG_upc_strict_type: return "DW_TAG_upc_strict_type";
- case DW_TAG_upc_relaxed_type: return "DW_TAG_upc_relaxed_type";
+ case DW_TAG_upc_shared_type: return "DW_TAG_upc_shared_type";
+ case DW_TAG_upc_strict_type: return "DW_TAG_upc_strict_type";
+ case DW_TAG_upc_relaxed_type: return "DW_TAG_upc_relaxed_type";
default:
{
static char buffer[100];
load_debug_loc (FILE *file)
{
Elf_Internal_Shdr *sec;
- unsigned int i;
/* If it is already loaded, do nothing. */
if (debug_loc_contents != NULL)
return;
/* Locate the .debug_loc section. */
- for (i = 0, sec = section_headers;
- i < elf_header.e_shnum;
- i++, sec++)
- if (strcmp (SECTION_NAME (sec), ".debug_loc") == 0)
- break;
-
- if (i == elf_header.e_shnum || sec->sh_size == 0)
+ sec = find_section (".debug_loc");
+ if (sec == NULL)
return;
debug_loc_size = sec->sh_size;
static int
display_debug_loc (Elf_Internal_Shdr *section,
- unsigned char *start,
- FILE *file ATTRIBUTE_UNUSED)
+ unsigned char *start, FILE *file)
{
unsigned char *section_end;
unsigned long bytes;
unsigned char *section_begin = start;
bfd_vma addr;
+ unsigned int comp_unit = 0;
addr = section->sh_addr;
bytes = section->sh_size;
return 0;
}
+ if (num_debug_line_pointer_sizes == 0)
+ get_debug_line_pointer_sizes (file);
+
printf (_("Contents of the .debug_loc section:\n\n"));
printf (_("\n Offset Begin End Expression\n"));
unsigned long end;
unsigned short length;
unsigned long offset;
+ unsigned int pointer_size;
offset = start - section_begin;
+ /* Get the pointer size from the comp unit associated
+ with this block of location information. */
+ if (comp_unit >= num_debug_line_pointer_sizes)
+ {
+ error (_("Not enough comp units for .debug_loc section\n"));
+ return 0;
+ }
+ else
+ {
+ pointer_size = debug_line_pointer_sizes [comp_unit];
+ comp_unit ++;
+ }
+
while (1)
{
- /* Normally, the lists in the debug_loc section are related to a
- given compilation unit, and thus, we would use the pointer size
- of that compilation unit. However, since we are displaying it
- separately here, we either have to store pointer sizes of all
- compilation units, or assume they don't change. We assume,
- like the debug_line display, that it doesn't change. */
- begin = byte_get (start, debug_line_pointer_size);
- start += debug_line_pointer_size;
- end = byte_get (start, debug_line_pointer_size);
- start += debug_line_pointer_size;
+ begin = byte_get (start, pointer_size);
+ start += pointer_size;
+ end = byte_get (start, pointer_size);
+ start += pointer_size;
if (begin == 0 && end == 0)
break;
start += 2;
printf (" %8.8lx %8.8lx %8.8lx (", offset, begin, end);
- decode_location_expression (start, debug_line_pointer_size, length);
+ decode_location_expression (start, pointer_size, length);
printf (")\n");
start += length;
load_debug_str (FILE *file)
{
Elf_Internal_Shdr *sec;
- unsigned int i;
/* If it is already loaded, do nothing. */
if (debug_str_contents != NULL)
return;
/* Locate the .debug_str section. */
- for (i = 0, sec = section_headers;
- i < elf_header.e_shnum;
- i++, sec++)
- if (strcmp (SECTION_NAME (sec), ".debug_str") == 0)
- break;
-
- if (i == elf_header.e_shnum || sec->sh_size == 0)
+ sec = find_section (".debug_str");
+ if (sec == NULL)
return;
debug_str_size = sec->sh_size;
data += offset_size;
}
else
- {
+ {
error (_("Internal error: DWARF version is not 2 or 3.\n"));
}
break;
case DW_FORM_addr:
printf (" %#lx", uvalue);
+ break;
case DW_FORM_flag:
case DW_FORM_data1:
return data;
}
+/* Apply addends of RELA relocations. */
+
+static int
+debug_apply_rela_addends (FILE *file,
+ Elf_Internal_Shdr *section,
+ int reloc_size,
+ unsigned char *sec_data,
+ unsigned char *start,
+ unsigned char *end)
+{
+ Elf_Internal_Shdr *relsec;
+
+ if (end - start < reloc_size)
+ return 1;
+
+ for (relsec = section_headers;
+ relsec < section_headers + elf_header.e_shnum;
+ ++relsec)
+ {
+ unsigned long nrelas;
+ Elf_Internal_Rela *rela, *rp;
+ Elf_Internal_Shdr *symsec;
+ Elf_Internal_Sym *symtab;
+ Elf_Internal_Sym *sym;
+
+ if (relsec->sh_type != SHT_RELA
+ || SECTION_HEADER (relsec->sh_info) != section
+ || relsec->sh_size == 0)
+ continue;
+
+ if (!slurp_rela_relocs (file, relsec->sh_offset, relsec->sh_size,
+ &rela, &nrelas))
+ return 0;
+
+ symsec = SECTION_HEADER (relsec->sh_link);
+ symtab = GET_ELF_SYMBOLS (file, symsec);
+
+ for (rp = rela; rp < rela + nrelas; ++rp)
+ {
+ unsigned char *loc;
+
+ if (rp->r_offset >= (bfd_vma) (start - sec_data)
+ && rp->r_offset < (bfd_vma) (end - sec_data) - reloc_size)
+ loc = sec_data + rp->r_offset;
+ else
+ continue;
+
+ if (is_32bit_elf)
+ {
+ sym = symtab + ELF32_R_SYM (rp->r_info);
+
+ if (ELF32_R_SYM (rp->r_info) != 0
+ && ELF32_ST_TYPE (sym->st_info) != STT_SECTION)
+ {
+ warn (_("Skipping unexpected symbol type %u\n"),
+ ELF32_ST_TYPE (sym->st_info));
+ continue;
+ }
+ }
+ else
+ {
+ sym = symtab + ELF64_R_SYM (rp->r_info);
+
+ if (ELF64_R_SYM (rp->r_info) != 0
+ && ELF64_ST_TYPE (sym->st_info) != STT_SECTION)
+ {
+ warn (_("Skipping unexpected symbol type %u\n"),
+ ELF64_ST_TYPE (sym->st_info));
+ continue;
+ }
+ }
+
+ byte_put (loc, rp->r_addend, reloc_size);
+ }
+
+ free (symtab);
+ free (rela);
+ break;
+ }
+ return 1;
+}
+
static int
display_debug_info (Elf_Internal_Shdr *section,
unsigned char *start,
while (start < end)
{
DWARF2_Internal_CompUnit compunit;
- Elf_Internal_Shdr *relsec;
unsigned char *hdrptr;
unsigned char *cu_abbrev_offset_ptr;
unsigned char *tags;
- unsigned int i;
int level;
unsigned long cu_offset;
int offset_size;
compunit.cu_version = byte_get (hdrptr, 2);
hdrptr += 2;
- /* Apply addends of RELA relocations. */
- for (relsec = section_headers;
- relsec < section_headers + elf_header.e_shnum;
- ++relsec)
- {
- unsigned long nrelas;
- Elf_Internal_Rela *rela, *rp;
- Elf_Internal_Shdr *symsec;
- Elf_Internal_Sym *symtab;
- Elf_Internal_Sym *sym;
-
- if (relsec->sh_type != SHT_RELA
- || SECTION_HEADER (relsec->sh_info) != section
- || relsec->sh_size == 0)
- continue;
-
- if (!slurp_rela_relocs (file, relsec->sh_offset, relsec->sh_size,
- & rela, & nrelas))
- return 0;
-
- symsec = SECTION_HEADER (relsec->sh_link);
- symtab = GET_ELF_SYMBOLS (file, symsec);
-
- for (rp = rela; rp < rela + nrelas; ++rp)
- {
- unsigned char *loc;
-
- if (rp->r_offset >= (bfd_vma) (hdrptr - section_begin)
- && section->sh_size > (bfd_vma) offset_size
- && rp->r_offset <= section->sh_size - offset_size)
- loc = section_begin + rp->r_offset;
- else
- continue;
-
- if (is_32bit_elf)
- {
- sym = symtab + ELF32_R_SYM (rp->r_info);
-
- if (ELF32_R_SYM (rp->r_info) != 0
- && ELF32_ST_TYPE (sym->st_info) != STT_SECTION)
- {
- warn (_("Skipping unexpected symbol type %u\n"),
- ELF32_ST_TYPE (sym->st_info));
- continue;
- }
- }
- else
- {
- sym = symtab + ELF64_R_SYM (rp->r_info);
-
- if (ELF64_R_SYM (rp->r_info) != 0
- && ELF64_ST_TYPE (sym->st_info) != STT_SECTION)
- {
- warn (_("Skipping unexpected symbol type %u\n"),
- ELF64_ST_TYPE (sym->st_info));
- continue;
- }
- }
-
- byte_put (loc, rp->r_addend, offset_size);
- }
+ cu_offset = start - section_begin;
+ start += compunit.cu_length + initial_length_size;
- free (rela);
- break;
- }
+ if (elf_header.e_type == ET_REL
+ && !debug_apply_rela_addends (file, section, offset_size,
+ section_begin, hdrptr, start))
+ return 0;
cu_abbrev_offset_ptr = hdrptr;
compunit.cu_abbrev_offset = byte_get (hdrptr, offset_size);
hdrptr += 1;
tags = hdrptr;
- cu_offset = start - section_begin;
- start += compunit.cu_length + initial_length_size;
printf (_(" Compilation Unit @ %lx:\n"), cu_offset);
printf (_(" Length: %ld\n"), compunit.cu_length);
unsigned char *begin;
/* Locate the .debug_abbrev section and process it. */
- for (i = 0, sec = section_headers;
- i < elf_header.e_shnum;
- i++, sec++)
- if (strcmp (SECTION_NAME (sec), ".debug_abbrev") == 0)
- break;
-
- if (i == elf_header.e_shnum || sec->sh_size == 0)
+ sec = find_section (".debug_abbrev");
+ if (sec == NULL)
{
warn (_("Unable to locate .debug_abbrev section!\n"));
return 0;
initial_length_size = 12;
}
else
- {
+ {
offset_size = 4;
initial_length_size = 4;
}
block_end = saved_start + length + initial_length_size;
cie_id = byte_get (start, offset_size); start += offset_size;
+ if (elf_header.e_type == ET_REL
+ && !debug_apply_rela_addends (file, section, offset_size,
+ section_start, start, block_end))
+ return 0;
+
if (is_eh ? (cie_id == 0) : (cie_id == DW_CIE_ID))
{
int version;
{
fc->code_factor = LEB ();
fc->data_factor = SLEB ();
- fc->ra = byte_get (start, 1); start += 1;
+ if (version == 1)
+ {
+ fc->ra = GET (1);
+ }
+ else
+ {
+ fc->ra = LEB ();
+ }
augmentation_data_len = LEB ();
augmentation_data = start;
start += augmentation_data_len;
start += addr_size;
fc->code_factor = LEB ();
fc->data_factor = SLEB ();
- fc->ra = byte_get (start, 1); start += 1;
+ if (version == 1)
+ {
+ fc->ra = GET (1);
+ }
+ else
+ {
+ fc->ra = LEB ();
+ }
}
else
{
fc->code_factor = LEB ();
fc->data_factor = SLEB ();
- fc->ra = byte_get (start, 1); start += 1;
+ if (version == 1)
+ {
+ fc->ra = GET (1);
+ }
+ else
+ {
+ fc->ra = LEB ();
+ }
}
cie = fc;
encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);
fc->pc_begin = get_encoded_value (start, fc->fde_encoding);
- if ((fc->fde_encoding & 0x70) == DW_EH_PE_pcrel)
+ if ((fc->fde_encoding & 0x70) == DW_EH_PE_pcrel
+ /* Don't adjust for ET_REL since there's invariably a pcrel
+ reloc here, which we haven't applied. */
+ && elf_header.e_type != ET_REL)
fc->pc_begin += section->sh_addr + (start - section_start);
start += encoded_ptr_size;
fc->pc_range = byte_get (start, encoded_ptr_size);
unsigned long i;
printf (" Augmentation data: ");
for (i = 0; i < augmentation_data_len; ++i)
- printf (" %02x", augmentation_data[i]);
+ printf (" %02x", augmentation_data[i]);
putchar ('\n');
putchar ('\n');
}
op &= 0xc0;
/* Warning: if you add any more cases to this switch, be
- sure to add them to the corresponding switch below. */
+ sure to add them to the corresponding switch below. */
switch (op)
{
case DW_CFA_advance_loc:
}
/* Now we know what registers are used, make a second pass over
- the chunk, this time actually printing out the info. */
+ the chunk, this time actually printing out the info. */
while (start < block_end)
{
case DW_CFA_set_loc:
vma = get_encoded_value (start, fc->fde_encoding);
- if ((fc->fde_encoding & 0x70) == DW_EH_PE_pcrel)
+ if ((fc->fde_encoding & 0x70) == DW_EH_PE_pcrel
+ && elf_header.e_type != ET_REL)
vma += section->sh_addr + (start - section_start);
start += encoded_ptr_size;
if (do_debug_frames_interp)
if (! do_debug_frames_interp)
printf (" DW_CFA_restore_state\n");
rs = remembered_state;
- remembered_state = rs->next;
- frame_need_space (fc, rs->ncols-1);
- memcpy (fc->col_type, rs->col_type, rs->ncols);
- memcpy (fc->col_offset, rs->col_offset, rs->ncols * sizeof (int));
- free (rs->col_type);
- free (rs->col_offset);
- free (rs);
+ if (rs)
+ {
+ remembered_state = rs->next;
+ frame_need_space (fc, rs->ncols-1);
+ memcpy (fc->col_type, rs->col_type, rs->ncols);
+ memcpy (fc->col_offset, rs->col_offset,
+ rs->ncols * sizeof (int));
+ free (rs->col_type);
+ free (rs->col_offset);
+ free (rs);
+ }
+ else if (do_debug_frames_interp)
+ printf ("Mismatched DW_CFA_restore_state\n");
break;
case DW_CFA_def_cfa:
return 1;
}
-/* Pre-scan the .debug_info section to record the size of address.
- When dumping the .debug_line, we use that size information, assuming
- that all compilation units have the same address size. */
-static int
-prescan_debug_info (Elf_Internal_Shdr *section ATTRIBUTE_UNUSED,
- unsigned char *start,
- FILE *file ATTRIBUTE_UNUSED)
-{
- unsigned long length;
-
- /* Read the first 4 bytes. For a 32-bit DWARF section, this will
- be the length. For a 64-bit DWARF section, it'll be the escape
- code 0xffffffff followed by an 8 byte length. For the purposes
- of this prescan, we don't care about the actual length, but the
- presence of the escape bytes does affect the location of the byte
- which describes the address size. */
- length = byte_get (start, 4);
-
- if (length == 0xffffffff)
- {
- /* For 64-bit DWARF, the 1-byte address_size field is 22 bytes
- from the start of the section. This is computed as follows:
-
- unit_length: 12 bytes
- version: 2 bytes
- debug_abbrev_offset: 8 bytes
- -----------------------------
- Total: 22 bytes */
-
- debug_line_pointer_size = byte_get (start + 22, 1);
- }
- else
- {
- /* For 32-bit DWARF, the 1-byte address_size field is 10 bytes from
- the start of the section:
- unit_length: 4 bytes
- version: 2 bytes
- debug_abbrev_offset: 4 bytes
- -----------------------------
- Total: 10 bytes */
-
- debug_line_pointer_size = byte_get (start + 10, 1);
- }
- return 0;
-}
-
- /* A structure containing the name of a debug section and a pointer
- to a function that can decode it. The third field is a prescan
- function to be run over the section before displaying any of the
- sections. */
+/* A structure containing the name of a debug section
+ and a pointer to a function that can decode it. */
struct
{
const char *const name;
int (*display) (Elf_Internal_Shdr *, unsigned char *, FILE *);
- int (*prescan) (Elf_Internal_Shdr *, unsigned char *, FILE *);
}
debug_displays[] =
{
- { ".debug_abbrev", display_debug_abbrev, NULL },
- { ".debug_aranges", display_debug_aranges, NULL },
- { ".debug_frame", display_debug_frames, NULL },
- { ".debug_info", display_debug_info, prescan_debug_info },
- { ".debug_line", display_debug_lines, NULL },
- { ".debug_pubnames", display_debug_pubnames, NULL },
- { ".eh_frame", display_debug_frames, NULL },
- { ".debug_macinfo", display_debug_macinfo, NULL },
- { ".debug_str", display_debug_str, NULL },
- { ".debug_loc", display_debug_loc, NULL },
- { ".debug_pubtypes", display_debug_not_supported, NULL },
- { ".debug_ranges", display_debug_not_supported, NULL },
- { ".debug_static_func", display_debug_not_supported, NULL },
- { ".debug_static_vars", display_debug_not_supported, NULL },
- { ".debug_types", display_debug_not_supported, NULL },
- { ".debug_weaknames", display_debug_not_supported, NULL }
+ { ".debug_abbrev", display_debug_abbrev },
+ { ".debug_aranges", display_debug_aranges },
+ { ".debug_frame", display_debug_frames },
+ { ".debug_info", display_debug_info },
+ { ".debug_line", display_debug_lines },
+ { ".debug_pubnames", display_debug_pubnames },
+ { ".eh_frame", display_debug_frames },
+ { ".debug_macinfo", display_debug_macinfo },
+ { ".debug_str", display_debug_str },
+ { ".debug_loc", display_debug_loc },
+ { ".debug_pubtypes", display_debug_pubnames },
+ { ".debug_ranges", display_debug_not_supported },
+ { ".debug_static_func", display_debug_not_supported },
+ { ".debug_static_vars", display_debug_not_supported },
+ { ".debug_types", display_debug_not_supported },
+ { ".debug_weaknames", display_debug_not_supported }
};
static int
if (! do_dump)
return 1;
- /* Pre-scan the debug sections to find some debug information not
- present in some of them. For the .debug_line, we must find out the
- size of address (specified in .debug_info and .debug_aranges). */
- for (i = 0, section = section_headers;
- i < elf_header.e_shnum && i < num_dump_sects;
- i++, section++)
- {
- char *name = SECTION_NAME (section);
- int j;
-
- if (section->sh_size == 0)
- continue;
-
- /* See if there is some pre-scan operation for this section. */
- for (j = NUM_ELEM (debug_displays); j--;)
- if (strcmp (debug_displays[j].name, name) == 0)
- {
- if (debug_displays[j].prescan != NULL)
- {
- bfd_size_type length;
- unsigned char *start;
-
- length = section->sh_size;
- start = get_data (NULL, file, section->sh_offset, length,
- _("debug section data"));
- if (!start)
- return 0;
-
- debug_displays[j].prescan (section, start, file);
- free (start);
- }
-
- break;
- }
- }
-
for (i = 0, section = section_headers;
i < elf_header.e_shnum && i < num_dump_sects;
i++, section++)
size_t conflicts_offset = 0;
/* We have a lot of special sections. Thanks SGI! */
- if (dynamic_segment == NULL)
+ if (dynamic_section == NULL)
/* No information available. */
return 0;
- for (entry = dynamic_segment; entry->d_tag != DT_NULL; ++entry)
+ for (entry = dynamic_section; entry->d_tag != DT_NULL; ++entry)
switch (entry->d_tag)
{
case DT_MIPS_LIBLIST:
free (econf64);
}
- printf (_("\nSection '.conflict' contains %ld entries:\n"),
- (long) conflictsno);
+ printf (_("\nSection '.conflict' contains %lu entries:\n"),
+ (unsigned long) conflictsno);
puts (_(" Num: Index Value Name"));
for (cnt = 0; cnt < conflictsno; ++cnt)
switch (e_type)
{
+ case NT_AUXV: return _("NT_AUXV (auxiliary vector)");
case NT_PRSTATUS: return _("NT_PRSTATUS (prstatus structure)");
case NT_FPREGSET: return _("NT_FPREGSET (floating point registers)");
case NT_PRPSINFO: return _("NT_PRPSINFO (prpsinfo structure)");
if (! process_file_header ())
return 1;
- if (! process_section_headers (file))
+ if (! process_section_headers (file)
+ || ! process_section_groups (file))
{
- /* Without loaded section headers we
+ /* Without loaded section headers and section groups we
cannot process lots of things. */
do_unwind = do_version = do_dump = do_arch = 0;
}
if (process_program_headers (file))
- process_dynamic_segment (file);
+ process_dynamic_section (file);
process_relocs (file);
dynamic_syminfo = NULL;
}
+ if (section_headers_groups)
+ {
+ free (section_headers_groups);
+ section_headers_groups = NULL;
+ }
+
+ if (section_groups)
+ {
+ struct group_list *g, *next;
+
+ for (i = 0; i < group_count; i++)
+ {
+ for (g = section_groups [i].root; g != NULL; g = next)
+ {
+ next = g->next;
+ free (g);
+ }
+ }
+
+ free (section_groups);
+ section_groups = NULL;
+ }
+
return 0;
}