/* readelf.c -- display contents of an ELF format file
- Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
- Free Software Foundation, Inc.
+ Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+ 2008 Free Software Foundation, Inc.
Originally developed by Eric Youngdale <eric@andante.jic.com>
Modifications by Nick Clifton <nickc@redhat.com>
: ((X)->sh_name >= string_table_length ? "<corrupt>" \
: string_table + (X)->sh_name))
-/* Given st_shndx I, map to section_headers index. */
-#define SECTION_HEADER_INDEX(I) \
- ((I) < SHN_LORESERVE \
- ? (I) \
- : ((I) <= SHN_HIRESERVE \
- ? 0 \
- : (I) - (SHN_HIRESERVE + 1 - SHN_LORESERVE)))
-
-/* Reverse of the above. */
-#define SECTION_HEADER_NUM(N) \
- ((N) < SHN_LORESERVE \
- ? (N) \
- : (N) + (SHN_HIRESERVE + 1 - SHN_LORESERVE))
-
-#define SECTION_HEADER(I) (section_headers + SECTION_HEADER_INDEX (I))
-
#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
#define BYTE_GET(field) byte_get (field, sizeof (field))
#if BFD_HOST_64BIT_LONG
return nc + printf ("%lx", vma);
#elif BFD_HOST_64BIT_LONG_LONG
+#ifndef __MSVCRT__
return nc + printf ("%llx", vma);
+#else
+ return nc + printf ("%I64x", vma);
+#endif
#else
return nc + print_hex_vma (vma);
#endif
#if BFD_HOST_64BIT_LONG
return printf ("%ld", vma);
#elif BFD_HOST_64BIT_LONG_LONG
+#ifndef __MSVCRT__
return printf ("%lld", vma);
+#else
+ return printf ("%I64d", vma);
+#endif
#else
return print_dec_vma (vma, 1);
#endif
else
return printf ("%#lx", vma);
#elif BFD_HOST_64BIT_LONG_LONG
+#ifndef __MSVCRT__
if (vma <= 99999)
return printf ("%5lld", vma);
else
return printf ("%#llx", vma);
+#else
+ if (vma <= 99999)
+ return printf ("%5I64d", vma);
+ else
+ return printf ("%#I64x", vma);
+#endif
#else
if (vma <= 99999)
return printf ("%5ld", _bfd_int64_low (vma));
#if BFD_HOST_64BIT_LONG
return printf ("%lu", vma);
#elif BFD_HOST_64BIT_LONG_LONG
+#ifndef __MSVCRT__
return printf ("%llu", vma);
+#else
+ return printf ("%I64u", vma);
+#endif
#else
return print_dec_vma (vma, 0);
#endif
/* Guess the relocation size commonly used by the specific machines. */
static int
-guess_is_rela (unsigned long e_machine)
+guess_is_rela (unsigned int e_machine)
{
switch (e_machine)
{
/* Display the contents of the relocation data found at the specified
offset. */
-static int
+static void
dump_relocations (FILE *file,
unsigned long rel_offset,
unsigned long rel_size,
if (is_rela)
{
if (!slurp_rela_relocs (file, rel_offset, rel_size, &rels, &rel_size))
- return 0;
+ return;
}
else
{
if (!slurp_rel_relocs (file, rel_offset, rel_size, &rels, &rel_size))
- return 0;
+ return;
}
if (is_32bit_elf)
: "%12.12lx %12.12lx ",
offset, info);
#elif BFD_HOST_64BIT_LONG_LONG
+#ifndef __MSVCRT__
printf (do_wide
? "%16.16llx %16.16llx "
: "%12.12llx %12.12llx ",
offset, info);
+#else
+ printf (do_wide
+ ? "%16.16I64x %16.16I64x "
+ : "%12.12I64x %12.12I64x ",
+ offset, info);
+#endif
#else
printf (do_wide
? "%8.8lx%8.8lx %8.8lx%8.8lx "
if (ELF_ST_TYPE (psym->st_info) == STT_SECTION)
{
- bfd_vma sec_index = (bfd_vma) -1;
-
- if (psym->st_shndx < SHN_LORESERVE)
- sec_index = psym->st_shndx;
- else if (psym->st_shndx > SHN_HIRESERVE)
- sec_index = psym->st_shndx - (SHN_HIRESERVE + 1
- - SHN_LORESERVE);
-
- if (sec_index != (bfd_vma) -1)
- sec_name = SECTION_NAME (section_headers + sec_index);
+ if (psym->st_shndx < elf_header.e_shnum)
+ sec_name
+ = SECTION_NAME (section_headers + psym->st_shndx);
else if (psym->st_shndx == SHN_ABS)
sec_name = "ABS";
else if (psym->st_shndx == SHN_COMMON)
&& elf_header.e_ident[EI_OSABI] == ELFOSABI_HPUX
&& psym->st_shndx == SHN_IA_64_ANSI_COMMON)
sec_name = "ANSI_COM";
+ else if (elf_header.e_machine == EM_IA_64
+ && (elf_header.e_ident[EI_OSABI]
+ == ELFOSABI_OPENVMS)
+ && psym->st_shndx == SHN_IA_64_VMS_SYMVEC)
+ sec_name = "VMS_SYMVEC";
else
{
sprintf (name_buf, "<section 0x%x>",
}
free (rels);
-
- return 1;
}
static const char *
{
switch (type)
{
- case DT_IA_64_PLT_RESERVE: return "IA_64_PLT_RESERVE";
+ case DT_IA_64_PLT_RESERVE: return "IA_64_PLT_RESERVE";
+ case DT_IA_64_VMS_SUBTYPE: return "VMS_SUBTYPE";
+ case DT_IA_64_VMS_IMGIOCNT: return "VMS_IMGIOCNT";
+ case DT_IA_64_VMS_LNKFLAGS: return "VMS_LNKFLAGS";
+ case DT_IA_64_VMS_VIR_MEM_BLK_SIZ: return "VMS_VIR_MEM_BLK_SIZ";
+ case DT_IA_64_VMS_IDENT: return "VMS_IDENT";
+ case DT_IA_64_VMS_NEEDED_IDENT: return "VMS_NEEDED_IDENT";
+ case DT_IA_64_VMS_IMG_RELA_CNT: return "VMS_IMG_RELA_CNT";
+ case DT_IA_64_VMS_SEG_RELA_CNT: return "VMS_SEG_RELA_CNT";
+ case DT_IA_64_VMS_FIXUP_RELA_CNT: return "VMS_FIXUP_RELA_CNT";
+ case DT_IA_64_VMS_FIXUP_NEEDED: return "VMS_FIXUP_NEEDED";
+ case DT_IA_64_VMS_SYMVEC_CNT: return "VMS_SYMVEC_CNT";
+ case DT_IA_64_VMS_XLATED: return "VMS_XLATED";
+ case DT_IA_64_VMS_STACKSIZE: return "VMS_STACKSIZE";
+ case DT_IA_64_VMS_UNWINDSZ: return "VMS_UNWINDSZ";
+ case DT_IA_64_VMS_UNWIND_CODSEG: return "VMS_UNWIND_CODSEG";
+ case DT_IA_64_VMS_UNWIND_INFOSEG: return "VMS_UNWIND_INFOSEG";
+ case DT_IA_64_VMS_LINKTIME: return "VMS_LINKTIME";
+ case DT_IA_64_VMS_SEG_NO: return "VMS_SEG_NO";
+ case DT_IA_64_VMS_SYMVEC_OFFSET: return "VMS_SYMVEC_OFFSET";
+ case DT_IA_64_VMS_SYMVEC_SEG: return "VMS_SYMVEC_SEG";
+ case DT_IA_64_VMS_UNWIND_OFFSET: return "VMS_UNWIND_OFFSET";
+ case DT_IA_64_VMS_UNWIND_SEG: return "VMS_UNWIND_SEG";
+ case DT_IA_64_VMS_STRTAB_OFFSET: return "VMS_STRTAB_OFFSET";
+ case DT_IA_64_VMS_SYSVER_OFFSET: return "VMS_SYSVER_OFFSET";
+ case DT_IA_64_VMS_IMG_RELA_OFF: return "VMS_IMG_RELA_OFF";
+ case DT_IA_64_VMS_SEG_RELA_OFF: return "VMS_SEG_RELA_OFF";
+ case DT_IA_64_VMS_FIXUP_RELA_OFF: return "VMS_FIXUP_RELA_OFF";
+ case DT_IA_64_VMS_PLTGOT_OFFSET: return "VMS_PLTGOT_OFFSET";
+ case DT_IA_64_VMS_PLTGOT_SEG: return "VMS_PLTGOT_SEG";
+ case DT_IA_64_VMS_FPMODE: return "VMS_FPMODE";
default:
return NULL;
}
case EM_PARISC:
result = get_parisc_dynamic_type (type);
break;
+ case EM_IA_64:
+ result = get_ia64_dynamic_type (type);
+ break;
default:
result = NULL;
break;
case E_MIPS_MACH_5500: strcat (buf, ", 5500"); break;
case E_MIPS_MACH_SB1: strcat (buf, ", sb1"); break;
case E_MIPS_MACH_9000: strcat (buf, ", 9000"); break;
+ case E_MIPS_MACH_LS2E: strcat (buf, ", loongson-2e"); break;
+ case E_MIPS_MACH_LS2F: strcat (buf, ", loongson-2f"); break;
+ case E_MIPS_MACH_OCTEON: strcat (buf, ", octeon"); break;
case 0:
/* We simply ignore the field in this case to avoid confusion:
MIPS ELF does not specify EF_MIPS_MACH, it is a GNU
switch (sh_type)
{
- case SHT_IA_64_EXT: return "IA_64_EXT";
- case SHT_IA_64_UNWIND: return "IA_64_UNWIND";
- case SHT_IA_64_PRIORITY_INIT: return "IA_64_PRIORITY_INIT";
+ case SHT_IA_64_EXT: return "IA_64_EXT";
+ case SHT_IA_64_UNWIND: return "IA_64_UNWIND";
+ case SHT_IA_64_PRIORITY_INIT: return "IA_64_PRIORITY_INIT";
+ case SHT_IA_64_VMS_TRACE: return "VMS_TRACE";
+ case SHT_IA_64_VMS_TIE_SIGNATURES: return "VMS_TIE_SIGNATURES";
+ case SHT_IA_64_VMS_DEBUG: return "VMS_DEBUG";
+ case SHT_IA_64_VMS_DEBUG_STR: return "VMS_DEBUG_STR";
+ case SHT_IA_64_VMS_LINKAGES: return "VMS_LINKAGES";
+ case SHT_IA_64_VMS_SYMBOL_VECTOR: return "VMS_SYMBOL_VECTOR";
+ case SHT_IA_64_VMS_FIXUP: return "VMS_FIXUP";
default:
break;
}
sprintf (buff, "LOPROC+%x", sh_type - SHT_LOPROC);
}
else if ((sh_type >= SHT_LOOS) && (sh_type <= SHT_HIOS))
- sprintf (buff, "LOOS+%x", sh_type - SHT_LOOS);
+ {
+ const char *result;
+
+ switch (elf_header.e_machine)
+ {
+ case EM_IA_64:
+ result = get_ia64_section_type_name (sh_type);
+ break;
+ default:
+ result = NULL;
+ break;
+ }
+
+ if (result != NULL)
+ return result;
+
+ sprintf (buff, "LOOS+%x", sh_type - SHT_LOOS);
+ }
else if ((sh_type >= SHT_LOUSER) && (sh_type <= SHT_HIUSER))
sprintf (buff, "LOUSER+%x", sh_type - SHT_LOUSER);
else
switch (optarg[index++])
{
case 'i':
- case 'I':
do_debug_info = 1;
break;
case 'a':
- case 'A':
do_debug_abbrevs = 1;
break;
case 'l':
- case 'L':
do_debug_lines = 1;
break;
case 'p':
- case 'P':
do_debug_pubnames = 1;
break;
break;
case 'm':
- case 'M':
do_debug_macinfo = 1;
break;
case 's':
- case 'S':
do_debug_str = 1;
break;
case 'o':
- case 'O':
do_debug_loc = 1;
break;
return 0;
}
+ init_dwarf_regnames (elf_header.e_machine);
+
if (do_header)
{
int i;
(long) elf_header.e_shentsize);
printf (_(" Number of section headers: %ld"),
(long) elf_header.e_shnum);
- if (section_headers != NULL && elf_header.e_shnum == 0)
+ if (section_headers != NULL && elf_header.e_shnum == SHN_UNDEF)
printf (" (%ld)", (long) section_headers[0].sh_size);
putc ('\n', stdout);
printf (_(" Section header string table index: %ld"),
(long) elf_header.e_shstrndx);
- if (section_headers != NULL && elf_header.e_shstrndx == SHN_XINDEX)
+ if (section_headers != NULL
+ && elf_header.e_shstrndx == (SHN_XINDEX & 0xffff))
printf (" (%ld)", (long) section_headers[0].sh_link);
- else if (elf_header.e_shstrndx != SHN_UNDEF
- && (elf_header.e_shstrndx >= elf_header.e_shnum
- || (elf_header.e_shstrndx >= SHN_LORESERVE
- && elf_header.e_shstrndx <= SHN_HIRESERVE)))
+ else if (elf_header.e_shstrndx >= elf_header.e_shnum)
printf (" <corrupt: out of range>");
putc ('\n', stdout);
}
if (section_headers != NULL)
{
- if (elf_header.e_shnum == 0)
+ if (elf_header.e_shnum == SHN_UNDEF)
elf_header.e_shnum = section_headers[0].sh_size;
- if (elf_header.e_shstrndx == SHN_XINDEX)
+ if (elf_header.e_shstrndx == (SHN_XINDEX & 0xffff))
elf_header.e_shstrndx = section_headers[0].sh_link;
- else if (elf_header.e_shstrndx != SHN_UNDEF
- && (elf_header.e_shstrndx >= elf_header.e_shnum
- || (elf_header.e_shstrndx >= SHN_LORESERVE
- && elf_header.e_shstrndx <= SHN_HIRESERVE)))
+ else if (elf_header.e_shstrndx >= elf_header.e_shnum)
elf_header.e_shstrndx = SHN_UNDEF;
free (section_headers);
section_headers = NULL;
shndx = NULL;
if (symtab_shndx_hdr != NULL
&& (symtab_shndx_hdr->sh_link
- == (unsigned long) SECTION_HEADER_NUM (section - section_headers)))
+ == (unsigned long) (section - section_headers)))
{
shndx = get_data (NULL, file, symtab_shndx_hdr->sh_offset,
1, symtab_shndx_hdr->sh_size, _("symtab shndx"));
psym->st_value = BYTE_GET (esyms[j].st_value);
psym->st_size = BYTE_GET (esyms[j].st_size);
psym->st_shndx = BYTE_GET (esyms[j].st_shndx);
- if (psym->st_shndx == SHN_XINDEX && shndx != NULL)
+ if (psym->st_shndx == (SHN_XINDEX & 0xffff) && shndx != NULL)
psym->st_shndx
= byte_get ((unsigned char *) &shndx[j], sizeof (shndx[j]));
+ else if (psym->st_shndx >= (SHN_LORESERVE & 0xffff))
+ psym->st_shndx += SHN_LORESERVE - (SHN_LORESERVE & 0xffff);
psym->st_info = BYTE_GET (esyms[j].st_info);
psym->st_other = BYTE_GET (esyms[j].st_other);
}
shndx = NULL;
if (symtab_shndx_hdr != NULL
&& (symtab_shndx_hdr->sh_link
- == (unsigned long) SECTION_HEADER_NUM (section - section_headers)))
+ == (unsigned long) (section - section_headers)))
{
shndx = get_data (NULL, file, symtab_shndx_hdr->sh_offset,
1, symtab_shndx_hdr->sh_size, _("symtab shndx"));
psym->st_info = BYTE_GET (esyms[j].st_info);
psym->st_other = BYTE_GET (esyms[j].st_other);
psym->st_shndx = BYTE_GET (esyms[j].st_shndx);
- if (psym->st_shndx == SHN_XINDEX && shndx != NULL)
+ if (psym->st_shndx == (SHN_XINDEX & 0xffff) && shndx != NULL)
psym->st_shndx
= byte_get ((unsigned char *) &shndx[j], sizeof (shndx[j]));
+ else if (psym->st_shndx >= (SHN_LORESERVE & 0xffff))
+ psym->st_shndx += SHN_LORESERVE - (SHN_LORESERVE & 0xffff);
psym->st_value = BYTE_GET (esyms[j].st_value);
psym->st_size = BYTE_GET (esyms[j].st_size);
}
bfd_vma os_flags = 0;
bfd_vma proc_flags = 0;
bfd_vma unknown_flags = 0;
- const struct
+ static const struct
{
const char *str;
int len;
{ "LINK ORDER", 10 },
{ "OS NONCONF", 10 },
{ "GROUP", 5 },
- { "TLS", 3 }
+ { "TLS", 3 },
+ /* IA-64 specific. */
+ { "SHORT", 5 },
+ { "NORECOV", 7 },
+ /* IA-64 OpenVMS specific. */
+ { "VMS_GLOBAL", 10 },
+ { "VMS_OVERLAID", 12 },
+ { "VMS_SHARED", 10 },
+ { "VMS_VECTOR", 10 },
+ { "VMS_ALLOC_64BIT", 15 },
+ { "VMS_PROTECTED", 13}
};
if (do_section_details)
default:
index = -1;
+ if (elf_header.e_machine == EM_IA_64)
+ {
+ if (flag == SHF_IA_64_SHORT)
+ index = 10;
+ else if (flag == SHF_IA_64_NORECOV)
+ index = 11;
+#ifdef BFD64
+ else if (elf_header.e_ident[EI_OSABI] == ELFOSABI_OPENVMS)
+ switch (flag)
+ {
+ case SHF_IA_64_VMS_GLOBAL: index = 12; break;
+ case SHF_IA_64_VMS_OVERLAID: index = 13; break;
+ case SHF_IA_64_VMS_SHARED: index = 14; break;
+ case SHF_IA_64_VMS_VECTOR: index = 15; break;
+ case SHF_IA_64_VMS_ALLOC_64BIT: index = 16; break;
+ case SHF_IA_64_VMS_PROTECTED: index = 17; break;
+ default: break;
+ }
+#endif
+ }
break;
}
/* Read in the string table, so that we have names to display. */
if (elf_header.e_shstrndx != SHN_UNDEF
- && SECTION_HEADER_INDEX (elf_header.e_shstrndx) < elf_header.e_shnum)
+ && elf_header.e_shstrndx < elf_header.e_shnum)
{
- section = SECTION_HEADER (elf_header.e_shstrndx);
+ section = section_headers + elf_header.e_shstrndx;
if (section->sh_size != 0)
{
eh_addr_size = 4;
break;
}
+ break;
+
+ case EM_M32C:
+ switch (elf_header.e_flags & EF_M32C_CPU_MASK)
+ {
+ case EF_M32C_CPU_M16C:
+ eh_addr_size = 2;
+ break;
+ }
+ break;
}
#define CHECK_ENTSIZE_VALUES(section, i, size32, size64) \
if (do_section_details)
{
printf (" [%2u] %s\n",
- SECTION_HEADER_NUM (i),
+ i,
SECTION_NAME (section));
if (is_32bit_elf || do_wide)
printf (" %-15.15s ",
}
else
printf (" [%2u] %-17.17s %-15.15s ",
- SECTION_HEADER_NUM (i),
+ i,
SECTION_NAME (section),
get_section_type_name (section->sh_type));
Elf_Internal_Sym *sym;
/* Get the symbol table. */
- if (SECTION_HEADER_INDEX (section->sh_link) >= elf_header.e_shnum
- || ((sec = SECTION_HEADER (section->sh_link))->sh_type
+ if (section->sh_link >= elf_header.e_shnum
+ || ((sec = section_headers + section->sh_link)->sh_type
!= SHT_SYMTAB))
{
error (_("Bad sh_link in group section `%s'\n"), name);
if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
{
- bfd_vma sec_index = SECTION_HEADER_INDEX (sym->st_shndx);
- if (sec_index == 0)
+ if (sym->st_shndx == 0
+ || sym->st_shndx >= elf_header.e_shnum)
{
error (_("Bad sh_info in group section `%s'\n"), name);
continue;
}
- group_name = SECTION_NAME (section_headers + sec_index);
+ group_name = SECTION_NAME (section_headers + sym->st_shndx);
strtab_sec = NULL;
if (strtab)
free (strtab);
else
{
/* Get the string table. */
- if (SECTION_HEADER_INDEX (symtab_sec->sh_link)
- >= elf_header.e_shnum)
+ if (symtab_sec->sh_link >= elf_header.e_shnum)
{
strtab_sec = NULL;
if (strtab)
strtab_size = 0;
}
else if (strtab_sec
- != (sec = SECTION_HEADER (symtab_sec->sh_link)))
+ != (sec = section_headers + symtab_sec->sh_link))
{
strtab_sec = sec;
if (strtab)
entry = byte_get (indices, 4);
indices += 4;
- if (SECTION_HEADER_INDEX (entry) >= elf_header.e_shnum)
+ if (entry >= elf_header.e_shnum)
{
error (_("section [%5u] in group section [%5u] > maximum section [%5u]\n"),
entry, i, elf_header.e_shnum - 1);
continue;
}
- else if (entry >= SHN_LORESERVE && entry <= SHN_HIRESERVE)
- {
- error (_("invalid section [%5u] in group section [%5u]\n"),
- entry, i);
- continue;
- }
- if (section_headers_groups [SECTION_HEADER_INDEX (entry)]
- != NULL)
+ if (section_headers_groups [entry] != NULL)
{
if (entry)
{
error (_("section [%5u] in group section [%5u] already in group section [%5u]\n"),
entry, i,
- section_headers_groups [SECTION_HEADER_INDEX (entry)]->group_index);
+ section_headers_groups [entry]->group_index);
continue;
}
else
if (!warned)
{
error (_("section 0 in group section [%5u]\n"),
- section_headers_groups [SECTION_HEADER_INDEX (entry)]->group_index);
+ section_headers_groups [entry]->group_index);
warned++;
}
}
}
- section_headers_groups [SECTION_HEADER_INDEX (entry)]
- = group;
+ section_headers_groups [entry] = group;
if (do_section_groups)
{
- sec = SECTION_HEADER (entry);
+ sec = section_headers + entry;
printf (" [%5u] %s\n", entry, SECTION_NAME (sec));
}
is_rela = section->sh_type == SHT_RELA;
- if (section->sh_link
- && SECTION_HEADER_INDEX (section->sh_link)
- < elf_header.e_shnum)
+ if (section->sh_link != 0
+ && section->sh_link < elf_header.e_shnum)
{
Elf_Internal_Shdr *symsec;
Elf_Internal_Sym *symtab;
unsigned long strtablen = 0;
char *strtab = NULL;
- symsec = SECTION_HEADER (section->sh_link);
+ symsec = section_headers + section->sh_link;
if (symsec->sh_type != SHT_SYMTAB
&& symsec->sh_type != SHT_DYNSYM)
continue;
if (symtab == NULL)
continue;
- if (SECTION_HEADER_INDEX (symsec->sh_link)
- < elf_header.e_shnum)
+ if (symsec->sh_link != 0
+ && symsec->sh_link < elf_header.e_shnum)
{
- strsec = SECTION_HEADER (symsec->sh_link);
+ strsec = section_headers + symsec->sh_link;
strtab = get_data (NULL, file, strsec->sh_offset,
1, strsec->sh_size,
}
free (table);
- /* Third, apply any relocations to the unwind table: */
-
+ /* Third, apply any relocations to the unwind table: */
for (relsec = section_headers;
relsec < section_headers + elf_header.e_shnum;
++relsec)
{
if (relsec->sh_type != SHT_RELA
- || SECTION_HEADER_INDEX (relsec->sh_info) >= elf_header.e_shnum
- || SECTION_HEADER (relsec->sh_info) != sec)
+ || relsec->sh_info >= elf_header.e_shnum
+ || section_headers + relsec->sh_info != sec)
continue;
if (!slurp_rela_relocs (file, relsec->sh_offset, relsec->sh_size,
for (i = 0, sec = section_headers; i < elf_header.e_shnum; ++i, ++sec)
{
if (sec->sh_type == SHT_SYMTAB
- && SECTION_HEADER_INDEX (sec->sh_link) < elf_header.e_shnum)
+ && sec->sh_link < elf_header.e_shnum)
{
aux.nsyms = sec->sh_size / sec->sh_entsize;
aux.symtab = GET_ELF_SYMBOLS (file, sec);
- strsec = SECTION_HEADER (sec->sh_link);
+ strsec = section_headers + sec->sh_link;
aux.strtab = get_data (NULL, file, strsec->sh_offset,
1, strsec->sh_size, _("string table"));
aux.strtab_size = aux.strtab != NULL ? strsec->sh_size : 0;
for (; g != NULL; g = g->next)
{
- sec = SECTION_HEADER (g->section_index);
+ sec = section_headers + g->section_index;
if (streq (SECTION_NAME (sec), ELF_STRING_ia64_unwind_info))
break;
free (table);
/* Third, apply any relocations to the unwind table. */
-
for (relsec = section_headers;
relsec < section_headers + elf_header.e_shnum;
++relsec)
{
if (relsec->sh_type != SHT_RELA
- || SECTION_HEADER_INDEX (relsec->sh_info) >= elf_header.e_shnum
- || SECTION_HEADER (relsec->sh_info) != sec)
+ || relsec->sh_info >= elf_header.e_shnum
+ || section_headers + relsec->sh_info != sec)
continue;
if (!slurp_rela_relocs (file, relsec->sh_offset, relsec->sh_size,
for (i = 0, sec = section_headers; i < elf_header.e_shnum; ++i, ++sec)
{
if (sec->sh_type == SHT_SYMTAB
- && SECTION_HEADER_INDEX (sec->sh_link) < elf_header.e_shnum)
+ && sec->sh_link < elf_header.e_shnum)
{
aux.nsyms = sec->sh_size / sec->sh_entsize;
aux.symtab = GET_ELF_SYMBOLS (file, sec);
- strsec = SECTION_HEADER (sec->sh_link);
+ strsec = section_headers + sec->sh_link;
aux.strtab = get_data (NULL, file, strsec->sh_offset,
1, strsec->sh_size, _("string table"));
aux.strtab_size = aux.strtab != NULL ? strsec->sh_size : 0;
printf_vma (section->sh_addr);
printf (_(" Offset: %#08lx Link: %lx (%s)\n"),
(unsigned long) section->sh_offset, section->sh_link,
- SECTION_HEADER_INDEX (section->sh_link)
- < elf_header.e_shnum
- ? SECTION_NAME (SECTION_HEADER (section->sh_link))
+ section->sh_link < elf_header.e_shnum
+ ? SECTION_NAME (section_headers + section->sh_link)
: "<corrupt>");
edefs = get_data (NULL, file, section->sh_offset, 1,
printf_vma (section->sh_addr);
printf (_(" Offset: %#08lx Link to section: %ld (%s)\n"),
(unsigned long) section->sh_offset, section->sh_link,
- SECTION_HEADER_INDEX (section->sh_link)
- < elf_header.e_shnum
- ? SECTION_NAME (SECTION_HEADER (section->sh_link))
+ section->sh_link < elf_header.e_shnum
+ ? SECTION_NAME (section_headers + section->sh_link)
: "<corrupt>");
eneed = get_data (NULL, file, section->sh_offset, 1,
Elf_Internal_Shdr *string_sec;
long off;
- if (SECTION_HEADER_INDEX (section->sh_link) >= elf_header.e_shnum)
+ if (section->sh_link >= elf_header.e_shnum)
break;
- link_section = SECTION_HEADER (section->sh_link);
+ link_section = section_headers + section->sh_link;
total = section->sh_size / sizeof (Elf_External_Versym);
- if (SECTION_HEADER_INDEX (link_section->sh_link)
- >= elf_header.e_shnum)
+ if (link_section->sh_link >= elf_header.e_shnum)
break;
found = 1;
symbols = GET_ELF_SYMBOLS (file, link_section);
- string_sec = SECTION_HEADER (link_section->sh_link);
+ string_sec = section_headers + link_section->sh_link;
strtab = get_data (NULL, file, string_sec->sh_offset, 1,
string_sec->sh_size, _("version string table"));
check_def = 1;
check_need = 1;
- if (SECTION_HEADER_INDEX (symbols[cnt + j].st_shndx)
- >= elf_header.e_shnum
- || SECTION_HEADER (symbols[cnt + j].st_shndx)->sh_type
+ if (symbols[cnt + j].st_shndx >= elf_header.e_shnum
+ || section_headers[symbols[cnt + j].st_shndx].sh_type
!= SHT_NOBITS)
{
if (symbols[cnt + j].st_shndx == SHN_UNDEF)
&& elf_header.e_machine == EM_MIPS)
return "SUND";
else if (type >= SHN_LOPROC && type <= SHN_HIPROC)
- sprintf (buff, "PRC[0x%04x]", type);
+ sprintf (buff, "PRC[0x%04x]", type & 0xffff);
else if (type >= SHN_LOOS && type <= SHN_HIOS)
- sprintf (buff, "OS [0x%04x]", type);
- else if (type >= SHN_LORESERVE && type <= SHN_HIRESERVE)
- sprintf (buff, "RSV[0x%04x]", type);
+ sprintf (buff, "OS [0x%04x]", type & 0xffff);
+ else if (type >= SHN_LORESERVE)
+ sprintf (buff, "RSV[0x%04x]", type & 0xffff);
else
sprintf (buff, "%3d", type);
break;
strtab = string_table;
strtab_size = string_table_length;
}
- else if (SECTION_HEADER_INDEX (section->sh_link) < elf_header.e_shnum)
+ else if (section->sh_link < elf_header.e_shnum)
{
Elf_Internal_Shdr *string_sec;
- string_sec = SECTION_HEADER (section->sh_link);
+ string_sec = section_headers + section->sh_link;
strtab = get_data (NULL, file, string_sec->sh_offset,
1, string_sec->sh_size, _("string table"));
vers_data = byte_get (data, 2);
- is_nobits = (SECTION_HEADER_INDEX (psym->st_shndx)
- < elf_header.e_shnum
- && SECTION_HEADER (psym->st_shndx)->sh_type
+ is_nobits = (psym->st_shndx < elf_header.e_shnum
+ && section_headers[psym->st_shndx].sh_type
== SHT_NOBITS);
check_def = (psym->st_shndx != SHN_UNDEF);
++relsec)
{
if ((relsec->sh_type != SHT_RELA && relsec->sh_type != SHT_REL)
- || SECTION_HEADER_INDEX (relsec->sh_info) >= elf_header.e_shnum
- || SECTION_HEADER (relsec->sh_info) != section
+ || relsec->sh_info >= elf_header.e_shnum
+ || section_headers + relsec->sh_info != section
|| relsec->sh_size == 0
- || SECTION_HEADER_INDEX (relsec->sh_link) >= elf_header.e_shnum)
+ || relsec->sh_link >= elf_header.e_shnum)
continue;
printf (_(" Note: This section has relocations against it, but these have NOT been applied to this dump.\n"));
if (data < end)
{
+#ifndef __MSVCRT__
printf (" [%6tx] %s\n", data - start, data);
+#else
+ printf (" [%6Ix] %s\n", (size_t) (data - start), data);
+#endif
data += strlen (data);
some_strings_shown = TRUE;
}
++relsec)
{
if ((relsec->sh_type != SHT_RELA && relsec->sh_type != SHT_REL)
- || SECTION_HEADER_INDEX (relsec->sh_info) >= elf_header.e_shnum
- || SECTION_HEADER (relsec->sh_info) != section
+ || relsec->sh_info >= elf_header.e_shnum
+ || section_headers + relsec->sh_info != section
|| relsec->sh_size == 0
- || SECTION_HEADER_INDEX (relsec->sh_link) >= elf_header.e_shnum)
+ || relsec->sh_link >= elf_header.e_shnum)
continue;
printf (_(" NOTE: This section has relocations against it, but these have NOT been applied to this dump.\n"));
{
switch (elf_header.e_machine)
{
+ case EM_386:
+ case EM_486:
+ return reloc_type == 1; /* R_386_32. */
case EM_68K:
return reloc_type == 1; /* R_68K_32. */
case EM_860:
return reloc_type == 1; /* R_860_32. */
case EM_ALPHA:
return reloc_type == 1; /* XXX Is this right ? */
+ case EM_ARC:
+ return reloc_type == 1; /* R_ARC_32. */
+ case EM_ARM:
+ return reloc_type == 2; /* R_ARM_ABS32 */
case EM_AVR_OLD:
case EM_AVR:
return reloc_type == 1;
return reloc_type == 15; /* R_CRX_NUM32. */
case EM_CYGNUS_FRV:
return reloc_type == 1;
+ case EM_CYGNUS_D10V:
+ case EM_D10V:
+ return reloc_type == 6; /* R_D10V_32. */
case EM_CYGNUS_D30V:
case EM_D30V:
return reloc_type == 12; /* R_D30V_32_NORMAL. */
+ case EM_DLX:
+ return reloc_type == 3; /* R_DLX_RELOC_32. */
case EM_CYGNUS_FR30:
case EM_FR30:
return reloc_type == 3; /* R_FR30_32. */
case EM_H8_300:
case EM_H8_300H:
return reloc_type == 1; /* R_H8_DIR32. */
+ case EM_IA_64:
+ return reloc_type == 0x65; /* R_IA64_SECREL32LSB. */
case EM_IP2K_OLD:
case EM_IP2K:
return reloc_type == 2; /* R_IP2K_32. */
return reloc_type == 1; /* R_MSP43_32. */
case EM_MT:
return reloc_type == 2; /* R_MT_32. */
+ case EM_ALTERA_NIOS2:
+ case EM_NIOS32:
+ return reloc_type == 1; /* R_NIOS_32. */
+ case EM_OPENRISC:
+ case EM_OR32:
+ return reloc_type == 1; /* R_OR32_32. */
case EM_PARISC:
return reloc_type == 1; /* R_PARISC_DIR32. */
case EM_PJ:
case EM_S390_OLD:
case EM_S390:
return reloc_type == 4; /* R_S390_32. */
+ case EM_SCORE:
+ return reloc_type == 8; /* R_SCORE_ABS32. */
case EM_SH:
return reloc_type == 1; /* R_SH_DIR32. */
case EM_SPARC32PLUS:
case EM_SPARC:
return reloc_type == 3 /* R_SPARC_32. */
|| reloc_type == 23; /* R_SPARC_UA32. */
+ case EM_SPU:
+ return reloc_type == 6; /* R_SPU_ADDR32 */
case EM_CYGNUS_V850:
case EM_V850:
return reloc_type == 6; /* R_V850_ABS32. */
case EM_XTENSA:
return reloc_type == 1; /* R_XTENSA_32. */
- case EM_ALTERA_NIOS2:
- /* Fall through (what reloc type is used ?). */
- case EM_NIOS32:
- case EM_IA_64:
- /* Fall through (what reloc type is used ?). */
default:
error (_("Missing knowledge of 32-bit reloc types used in DWARF sections of machine number %d\n"),
elf_header.e_machine);
{
switch (elf_header.e_machine)
{
+ case EM_386:
+ case EM_486:
+ return reloc_type == 2; /* R_386_PC32. */
case EM_68K:
- return reloc_type == 4; /* R_68K_PC32. */
+ return reloc_type == 4; /* R_68K_PC32. */
case EM_ALPHA:
return reloc_type == 10; /* R_ALPHA_SREL32. */
+ case EM_ARM:
+ return reloc_type == 3; /* R_ARM_REL32 */
case EM_PARISC:
- return reloc_type == 0; /* R_PARISC_NONE. *//* FIXME: This reloc is generated, but it may be a bug. */
+ return reloc_type == 0; /* R_PARISC_NONE. *//* FIXME: This reloc is generated, but it may be a bug. */
case EM_PPC:
return reloc_type == 26; /* R_PPC_REL32. */
case EM_PPC64:
- return reloc_type == 26; /* R_PPC64_REL32. */
+ return reloc_type == 26; /* R_PPC64_REL32. */
case EM_S390_OLD:
case EM_S390:
- return reloc_type == 5; /* R_390_PC32. */
+ return reloc_type == 5; /* R_390_PC32. */
case EM_SH:
- return reloc_type == 2; /* R_SH_REL32. */
+ return reloc_type == 2; /* R_SH_REL32. */
case EM_SPARC32PLUS:
case EM_SPARCV9:
case EM_SPARC:
- return reloc_type == 6; /* R_SPARC_DISP32. */
+ return reloc_type == 6; /* R_SPARC_DISP32. */
+ case EM_SPU:
+ return reloc_type == 13; /* R_SPU_REL32. */
case EM_X86_64:
- return reloc_type == 2; /* R_X86_64_PC32. */
+ return reloc_type == 2; /* R_X86_64_PC32. */
+ case EM_XTENSA_OLD:
+ case EM_XTENSA:
+ return reloc_type == 14; /* R_XTENSA_32_PCREL. */
default:
/* Do not abort or issue an error message here. Not all targets use
pc-relative 32-bit relocs in their DWARF debug information and we
have already tested for target coverage in is_32bit_abs_reloc. A
- more helpful warning message will be generated by debug_apply_rela_addends
- anyway, so just return. */
+ more helpful warning message will be generated by
+ debug_apply_relocations anyway, so just return. */
return FALSE;
}
}
{
case EM_ALPHA:
return reloc_type == 2; /* R_ALPHA_REFQUAD. */
+ case EM_IA_64:
+ return reloc_type == 0x27; /* R_IA64_DIR64LSB. */
+ case EM_PARISC:
+ return reloc_type == 80; /* R_PARISC_DIR64. */
case EM_PPC64:
return reloc_type == 38; /* R_PPC64_ADDR64. */
case EM_SPARC32PLUS:
return reloc_type == 54; /* R_SPARC_UA64. */
case EM_X86_64:
return reloc_type == 1; /* R_X86_64_64. */
+ case EM_S390_OLD:
+ case EM_S390:
+ return reloc_type == 22; /* R_S390_64 */
default:
return FALSE;
}
case EM_AVR_OLD:
case EM_AVR:
return reloc_type == 4; /* R_AVR_16. */
+ case EM_CYGNUS_D10V:
+ case EM_D10V:
+ return reloc_type == 3; /* R_D10V_16. */
case EM_H8S:
case EM_H8_300:
case EM_H8_300H:
case EM_IP2K_OLD:
case EM_IP2K:
return reloc_type == 1; /* R_IP2K_16. */
+ case EM_M32C:
+ return reloc_type == 1; /* R_M32C_16 */
case EM_MSP430_OLD:
case EM_MSP430:
return reloc_type == 5; /* R_MSP430_16_BYTE. */
+ case EM_ALTERA_NIOS2:
+ case EM_NIOS32:
+ return reloc_type == 9; /* R_NIOS_16. */
default:
return FALSE;
}
}
-/* Apply addends of RELA relocations. */
+/* Apply relocations to a debug section. */
-static int
-debug_apply_rela_addends (void *file,
- Elf_Internal_Shdr *section,
- unsigned char *start)
+static void
+debug_apply_relocations (void *file,
+ Elf_Internal_Shdr *section,
+ unsigned char *start)
{
Elf_Internal_Shdr *relsec;
unsigned char *end = start + section->sh_size;
- if (!is_relocatable)
- return 1;
-
- /* SH uses RELA but uses in place value instead of the addend field. */
- if (elf_header.e_machine == EM_SH)
- return 0;
+ if (elf_header.e_type != ET_REL)
+ return;
+ /* Find the reloc section associated with the debug section. */
for (relsec = section_headers;
relsec < section_headers + elf_header.e_shnum;
++relsec)
{
- unsigned long nrelas;
- Elf_Internal_Rela *rela, *rp;
+ bfd_boolean is_rela;
+ unsigned long num_relocs;
+ Elf_Internal_Rela *relocs, *rp;
Elf_Internal_Shdr *symsec;
Elf_Internal_Sym *symtab;
Elf_Internal_Sym *sym;
- if (relsec->sh_type != SHT_RELA
- || SECTION_HEADER_INDEX (relsec->sh_info) >= elf_header.e_shnum
- || SECTION_HEADER (relsec->sh_info) != section
+ if ((relsec->sh_type != SHT_RELA && relsec->sh_type != SHT_REL)
+ || relsec->sh_info >= elf_header.e_shnum
+ || section_headers + relsec->sh_info != section
|| relsec->sh_size == 0
- || SECTION_HEADER_INDEX (relsec->sh_link) >= elf_header.e_shnum)
+ || relsec->sh_link >= elf_header.e_shnum)
continue;
- if (!slurp_rela_relocs (file, relsec->sh_offset, relsec->sh_size,
- &rela, &nrelas))
- return 0;
+ is_rela = relsec->sh_type == SHT_RELA;
- symsec = SECTION_HEADER (relsec->sh_link);
+ if (is_rela)
+ {
+ if (!slurp_rela_relocs (file, relsec->sh_offset, relsec->sh_size,
+ & relocs, & num_relocs))
+ return;
+ }
+ else
+ {
+ if (!slurp_rel_relocs (file, relsec->sh_offset, relsec->sh_size,
+ & relocs, & num_relocs))
+ return;
+ }
+
+ /* SH uses RELA but uses in place value instead of the addend field. */
+ if (elf_header.e_machine == EM_SH)
+ is_rela = FALSE;
+
+ symsec = section_headers + relsec->sh_link;
symtab = GET_ELF_SYMBOLS (file, symsec);
- for (rp = rela; rp < rela + nrelas; ++rp)
+ for (rp = relocs; rp < relocs + num_relocs; ++rp)
{
- unsigned int reloc_type;
- unsigned int reloc_size;
- unsigned char *loc;
+ bfd_vma addend;
+ unsigned int reloc_type;
+ unsigned int reloc_size;
+ unsigned char * loc;
/* In MIPS little-endian objects, r_info isn't really a
64-bit little-endian value: it has a 32-bit little-endian
| ((rp->r_info >> 24) & 0xff0000)
| ((rp->r_info >> 8) & 0xff000000));
- sym = symtab + get_reloc_symindex (rp->r_info);
reloc_type = get_reloc_type (rp->r_info);
+
if (is_32bit_abs_reloc (reloc_type)
|| is_32bit_pcrel_reloc (reloc_type))
reloc_size = 4;
reloc_size = 2;
else
{
- warn (_("skipping unsupported reloc type %d in section .rela%s\n"),
+ warn (_("unable to apply unsupported reloc type %d to section %s\n"),
reloc_type, SECTION_NAME (section));
continue;
}
continue;
}
+ sym = symtab + get_reloc_symindex (rp->r_info);
+
+ /* If the reloc has a symbol associated with it,
+ make sure that it is of an appropriate type. */
if (sym != symtab
&& ELF_ST_TYPE (sym->st_info) != STT_SECTION
/* Relocations against symbols without type can happen.
example of this see the _clz.o binary in libgcc.a. */
&& ELF_ST_TYPE (sym->st_info) != STT_OBJECT)
{
- warn (_("skipping unexpected symbol type %s in relocation in section .rela%s\n"),
+ warn (_("skipping unexpected symbol type %s in %ld'th relocation in section %s\n"),
get_symbol_type (ELF_ST_TYPE (sym->st_info)),
- SECTION_NAME (section));
+ (long int)(rp - relocs),
+ SECTION_NAME (relsec));
continue;
}
+ addend = is_rela ? rp->r_addend : byte_get (loc, reloc_size);
+
if (is_32bit_pcrel_reloc (reloc_type))
- /* FIXME: Not sure how to apply a pc-rel reloc yet.
- I think that it ought to be:
- (rp->r_addend + sym->st_value) - rp->r_offset
- but this breaks GAS CFI tests... */
- byte_put (loc, (rp->r_addend + sym->st_value) /*- rp->r_offset*/, reloc_size);
+ byte_put (loc, (addend + sym->st_value) - rp->r_offset,
+ reloc_size);
else
- byte_put (loc, rp->r_addend + sym->st_value, reloc_size);
+ byte_put (loc, addend + sym->st_value, reloc_size);
}
free (symtab);
- free (rela);
+ free (relocs);
break;
}
- return 1;
}
int
sec->sh_size, buf);
if (debug_displays [debug].relocate)
- debug_apply_rela_addends (file, sec, section->start);
+ debug_apply_relocations (file, sec, section->start);
return section->start != NULL;
}
static const char *arm_attr_tag_ARM_ISA_use[] = {"No", "Yes"};
static const char *arm_attr_tag_THUMB_ISA_use[] =
{"No", "Thumb-1", "Thumb-2"};
-/* FIXME: VFPv3 encoding was extrapolated! */
-static const char *arm_attr_tag_VFP_arch[] = {"No", "VFPv1", "VFPv2", "VFPv3"};
+static const char *arm_attr_tag_VFP_arch[] =
+ {"No", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16"};
static const char *arm_attr_tag_WMMX_arch[] = {"No", "WMMXv1"};
static const char *arm_attr_tag_NEON_arch[] = {"No", "NEONv1"};
static const char *arm_attr_tag_ABI_PCS_config[] =
case 3:
printf ("Soft float\n");
break;
+ case 4:
+ printf ("64-bit float (-mips32r2 -mfp64)\n");
+ break;
default:
printf ("??? (%d)\n", val);
break;
switch (section->sh_type)
{
case SHT_GNU_LIBLIST:
- if (SECTION_HEADER_INDEX (section->sh_link) >= elf_header.e_shnum)
+ if (section->sh_link >= elf_header.e_shnum)
break;
elib = get_data (NULL, file, section->sh_offset, 1, section->sh_size,
if (elib == NULL)
break;
- string_sec = SECTION_HEADER (section->sh_link);
+ string_sec = section_headers + section->sh_link;
strtab = get_data (NULL, file, string_sec->sh_offset, 1,
string_sec->sh_size, _("liblist string table"));
get_64bit_section_headers (file, 1);
}
- is_relocatable = elf_header.e_type == ET_REL;
-
return 1;
}