aboutsummaryrefslogtreecommitdiff
path: root/binutils/readelf.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2009-09-10 13:40:44 +0000
committerNick Clifton <nickc@redhat.com>2009-09-10 13:40:44 +0000
commit3f5e193bd6e036c43af9326d777aed6cfc14fbcb (patch)
treeca5ab96592667cbb90238e7b707b8655b9afbf00 /binutils/readelf.c
parentc8676ae4523f210705553322445efeae9df702b0 (diff)
downloadgdb-3f5e193bd6e036c43af9326d777aed6cfc14fbcb.zip
gdb-3f5e193bd6e036c43af9326d777aed6cfc14fbcb.tar.gz
gdb-3f5e193bd6e036c43af9326d777aed6cfc14fbcb.tar.bz2
Updated soruces in binutils/* to compile cleanly with -Wc++-compat.
* binutils/addr2line.c (slurp_symtab): Fix casts. Introduce variable minisyms to avoid aliasing varning. * binutils/ar.c: Add casts. (normalize): Use name del instead of delete. (display_target_list,display_info_table): Change loop counter variable a to int. * binutils/bucomm.c: Add casts. * binutils/debug.c: Update function to use new names. (struct debug_baseclass): Rename member from virtual to is_virtual. (struct debug_type_s,struct debug_field_s,struct debug_baseclass_s,struct debug_method_s,struct debug_method_variant_s,struct debug_type_s): Rename struct from avoid name collision. * /binutils/debug.h: Use new struct names. * binutils/dwarf.c: Add casts. (free_debug_memory): Change loop counter variable a to int. * binutils/ieee.c: Add casts. (enum ieee_var_kind): Move to top level. (ieee_class_baseclass): Rename parameter virtual to is_virtual. (ieee_class_method_var): Rename variable virtual to is_virtual. * binutils/nm.c: Add casts. * binutils/objcopy.c: Add casts. (copy_archive): Rename variable delete to del. * binutils/objdump.c: Add casts. (dump_dwarf_section): Change loop counter variable i to int. * binutils/prdbg.c: Add casts. (pr_class_baseclass,tg_class_baseclass): Rename parameters virtual to is_virtual. * binutils/readelf.c: Add casts. (struct ia64_unw_table_entry,struct hppa_unw_table_entry): Move to top level. * binutils/size.c: Add casts. * binutils/stabs.c (parse_stab_type, parse_stab_range_type) (parse_stab_cpp_abbrev): Rename parameter from typename to type_name. (parse_stab_baseclasses): Rename variable virtual to is_virtual. * binutils/strings.c: Add casts. * binutils/wrstabs.c (stab_class_baseclass): Rename parameter virtual to is_virtual.
Diffstat (limited to 'binutils/readelf.c')
-rw-r--r--binutils/readelf.c410
1 files changed, 232 insertions, 178 deletions
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 872ec09..afa7d2a 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -662,13 +662,15 @@ slurp_rela_relocs (FILE * file,
{
Elf32_External_Rela * erelas;
- erelas = get_data (NULL, file, rel_offset, 1, rel_size, _("relocs"));
+ erelas = (Elf32_External_Rela *) get_data (NULL, file, rel_offset, 1,
+ rel_size, _("relocs"));
if (!erelas)
return 0;
nrelas = rel_size / sizeof (Elf32_External_Rela);
- relas = cmalloc (nrelas, sizeof (Elf_Internal_Rela));
+ relas = (Elf_Internal_Rela *) cmalloc (nrelas,
+ sizeof (Elf_Internal_Rela));
if (relas == NULL)
{
@@ -690,13 +692,15 @@ slurp_rela_relocs (FILE * file,
{
Elf64_External_Rela * erelas;
- erelas = get_data (NULL, file, rel_offset, 1, rel_size, _("relocs"));
+ erelas = (Elf64_External_Rela *) get_data (NULL, file, rel_offset, 1,
+ rel_size, _("relocs"));
if (!erelas)
return 0;
nrelas = rel_size / sizeof (Elf64_External_Rela);
- relas = cmalloc (nrelas, sizeof (Elf_Internal_Rela));
+ relas = (Elf_Internal_Rela *) cmalloc (nrelas,
+ sizeof (Elf_Internal_Rela));
if (relas == NULL)
{
@@ -756,13 +760,14 @@ slurp_rel_relocs (FILE * file,
{
Elf32_External_Rel * erels;
- erels = get_data (NULL, file, rel_offset, 1, rel_size, _("relocs"));
+ erels = (Elf32_External_Rel *) get_data (NULL, file, rel_offset, 1,
+ rel_size, _("relocs"));
if (!erels)
return 0;
nrels = rel_size / sizeof (Elf32_External_Rel);
- rels = cmalloc (nrels, sizeof (Elf_Internal_Rela));
+ rels = (Elf_Internal_Rela *) cmalloc (nrels, sizeof (Elf_Internal_Rela));
if (rels == NULL)
{
@@ -784,13 +789,14 @@ slurp_rel_relocs (FILE * file,
{
Elf64_External_Rel * erels;
- erels = get_data (NULL, file, rel_offset, 1, rel_size, _("relocs"));
+ erels = (Elf64_External_Rel *) get_data (NULL, file, rel_offset, 1,
+ rel_size, _("relocs"));
if (!erels)
return 0;
nrels = rel_size / sizeof (Elf64_External_Rel);
- rels = cmalloc (nrels, sizeof (Elf_Internal_Rela));
+ rels = (Elf_Internal_Rela *) cmalloc (nrels, sizeof (Elf_Internal_Rela));
if (rels == NULL)
{
@@ -2941,7 +2947,8 @@ request_dump_bynumber (unsigned int section, dump_type type)
{
dump_type * new_dump_sects;
- new_dump_sects = calloc (section + 1, sizeof (* dump_sects));
+ new_dump_sects = (dump_type *) calloc (section + 1,
+ sizeof (* dump_sects));
if (new_dump_sects == NULL)
error (_("Out of memory allocating dump request table.\n"));
@@ -2970,7 +2977,8 @@ request_dump_byname (const char * section, dump_type type)
{
struct dump_list_entry * new_request;
- new_request = malloc (sizeof (struct dump_list_entry));
+ new_request = (struct dump_list_entry *)
+ malloc (sizeof (struct dump_list_entry));
if (!new_request)
error (_("Out of memory allocating dump request table.\n"));
@@ -3289,9 +3297,10 @@ get_32bit_program_headers (FILE * file, Elf_Internal_Phdr * program_headers)
Elf_Internal_Phdr * internal;
unsigned int i;
- phdrs = get_data (NULL, file, elf_header.e_phoff,
- elf_header.e_phentsize, elf_header.e_phnum,
- _("program headers"));
+ phdrs = (Elf32_External_Phdr *) get_data (NULL, file, elf_header.e_phoff,
+ elf_header.e_phentsize,
+ elf_header.e_phnum,
+ _("program headers"));
if (!phdrs)
return 0;
@@ -3322,9 +3331,10 @@ get_64bit_program_headers (FILE * file, Elf_Internal_Phdr * program_headers)
Elf_Internal_Phdr * internal;
unsigned int i;
- phdrs = get_data (NULL, file, elf_header.e_phoff,
- elf_header.e_phentsize, elf_header.e_phnum,
- _("program headers"));
+ phdrs = (Elf64_External_Phdr *) get_data (NULL, file, elf_header.e_phoff,
+ elf_header.e_phentsize,
+ elf_header.e_phnum,
+ _("program headers"));
if (!phdrs)
return 0;
@@ -3358,7 +3368,8 @@ get_program_headers (FILE * file)
if (program_headers != NULL)
return 1;
- phdrs = cmalloc (elf_header.e_phnum, sizeof (Elf_Internal_Phdr));
+ phdrs = (Elf_Internal_Phdr *) cmalloc (elf_header.e_phnum,
+ sizeof (Elf_Internal_Phdr));
if (phdrs == NULL)
{
@@ -3651,12 +3662,14 @@ get_32bit_section_headers (FILE * file, unsigned int num)
Elf_Internal_Shdr * internal;
unsigned int i;
- shdrs = get_data (NULL, file, elf_header.e_shoff,
- elf_header.e_shentsize, num, _("section headers"));
+ shdrs = (Elf32_External_Shdr *) get_data (NULL, file, elf_header.e_shoff,
+ elf_header.e_shentsize, num,
+ _("section headers"));
if (!shdrs)
return 0;
- section_headers = cmalloc (num, sizeof (Elf_Internal_Shdr));
+ section_headers = (Elf_Internal_Shdr *) cmalloc (num,
+ sizeof (Elf_Internal_Shdr));
if (section_headers == NULL)
{
@@ -3692,12 +3705,14 @@ get_64bit_section_headers (FILE * file, unsigned int num)
Elf_Internal_Shdr * internal;
unsigned int i;
- shdrs = get_data (NULL, file, elf_header.e_shoff,
- elf_header.e_shentsize, num, _("section headers"));
+ shdrs = (Elf64_External_Shdr *) get_data (NULL, file, elf_header.e_shoff,
+ elf_header.e_shentsize, num,
+ _("section headers"));
if (!shdrs)
return 0;
- section_headers = cmalloc (num, sizeof (Elf_Internal_Shdr));
+ section_headers = (Elf_Internal_Shdr *) cmalloc (num,
+ sizeof (Elf_Internal_Shdr));
if (section_headers == NULL)
{
@@ -3736,8 +3751,8 @@ get_32bit_elf_symbols (FILE * file, Elf_Internal_Shdr * section)
Elf_Internal_Sym * psym;
unsigned int j;
- esyms = get_data (NULL, file, section->sh_offset, 1, section->sh_size,
- _("symbols"));
+ esyms = (Elf32_External_Sym *) get_data (NULL, file, section->sh_offset, 1,
+ section->sh_size, _("symbols"));
if (!esyms)
return NULL;
@@ -3746,8 +3761,10 @@ get_32bit_elf_symbols (FILE * file, Elf_Internal_Shdr * section)
&& (symtab_shndx_hdr->sh_link
== (unsigned long) (section - section_headers)))
{
- shndx = get_data (NULL, file, symtab_shndx_hdr->sh_offset,
- 1, symtab_shndx_hdr->sh_size, _("symtab shndx"));
+ shndx = (Elf_External_Sym_Shndx *) get_data (NULL, file,
+ symtab_shndx_hdr->sh_offset,
+ 1, symtab_shndx_hdr->sh_size,
+ _("symtab shndx"));
if (!shndx)
{
free (esyms);
@@ -3756,7 +3773,7 @@ get_32bit_elf_symbols (FILE * file, Elf_Internal_Shdr * section)
}
number = section->sh_size / section->sh_entsize;
- isyms = cmalloc (number, sizeof (Elf_Internal_Sym));
+ isyms = (Elf_Internal_Sym *) cmalloc (number, sizeof (Elf_Internal_Sym));
if (isyms == NULL)
{
@@ -3801,8 +3818,8 @@ get_64bit_elf_symbols (FILE * file, Elf_Internal_Shdr * section)
Elf_Internal_Sym * psym;
unsigned int j;
- esyms = get_data (NULL, file, section->sh_offset, 1, section->sh_size,
- _("symbols"));
+ esyms = (Elf64_External_Sym *) get_data (NULL, file, section->sh_offset, 1,
+ section->sh_size, _("symbols"));
if (!esyms)
return NULL;
@@ -3811,8 +3828,10 @@ get_64bit_elf_symbols (FILE * file, Elf_Internal_Shdr * section)
&& (symtab_shndx_hdr->sh_link
== (unsigned long) (section - section_headers)))
{
- shndx = get_data (NULL, file, symtab_shndx_hdr->sh_offset,
- 1, symtab_shndx_hdr->sh_size, _("symtab shndx"));
+ shndx = (Elf_External_Sym_Shndx *) get_data (NULL, file,
+ symtab_shndx_hdr->sh_offset,
+ 1, symtab_shndx_hdr->sh_size,
+ _("symtab shndx"));
if (!shndx)
{
free (esyms);
@@ -3821,7 +3840,7 @@ get_64bit_elf_symbols (FILE * file, Elf_Internal_Shdr * section)
}
number = section->sh_size / section->sh_entsize;
- isyms = cmalloc (number, sizeof (Elf_Internal_Sym));
+ isyms = (Elf_Internal_Sym *) cmalloc (number, sizeof (Elf_Internal_Sym));
if (isyms == NULL)
{
@@ -4113,8 +4132,9 @@ process_section_headers (FILE * file)
if (section->sh_size != 0)
{
- string_table = get_data (NULL, file, section->sh_offset,
- 1, section->sh_size, _("string table"));
+ string_table = (char *) get_data (NULL, file, section->sh_offset,
+ 1, section->sh_size,
+ _("string table"));
string_table_length = string_table != NULL ? section->sh_size : 0;
}
@@ -4218,8 +4238,9 @@ process_section_headers (FILE * file)
continue;
}
- dynamic_strings = get_data (NULL, file, section->sh_offset,
- 1, section->sh_size, _("dynamic strings"));
+ dynamic_strings = (char *) get_data (NULL, file, section->sh_offset,
+ 1, section->sh_size,
+ _("dynamic strings"));
dynamic_strings_length = section->sh_size;
}
else if (section->sh_type == SHT_SYMTAB_SHNDX)
@@ -4544,8 +4565,8 @@ process_section_groups (FILE * file)
abort ();
}
- section_headers_groups = calloc (elf_header.e_shnum,
- sizeof (struct group *));
+ section_headers_groups = (struct group **) calloc (elf_header.e_shnum,
+ sizeof (struct group *));
if (section_headers_groups == NULL)
{
@@ -4569,7 +4590,7 @@ process_section_groups (FILE * file)
return 1;
}
- section_groups = calloc (group_count, sizeof (struct group));
+ section_groups = (struct group *) calloc (group_count, sizeof (struct group));
if (section_groups == NULL)
{
@@ -4648,17 +4669,18 @@ process_section_groups (FILE * file)
strtab_sec = sec;
if (strtab)
free (strtab);
- strtab = get_data (NULL, file, strtab_sec->sh_offset,
- 1, strtab_sec->sh_size,
- _("string table"));
+ strtab = (char *) get_data (NULL, file, strtab_sec->sh_offset,
+ 1, strtab_sec->sh_size,
+ _("string table"));
strtab_size = strtab != NULL ? strtab_sec->sh_size : 0;
}
group_name = sym->st_name < strtab_size
? strtab + sym->st_name : "<corrupt>";
}
- start = get_data (NULL, file, section->sh_offset,
- 1, section->sh_size, _("section data"));
+ start = (unsigned char *) get_data (NULL, file, section->sh_offset,
+ 1, section->sh_size,
+ _("section data"));
indices = start;
size = (section->sh_size / section->sh_entsize) - 1;
@@ -4721,7 +4743,7 @@ process_section_groups (FILE * file)
printf (" [%5u] %s\n", entry, SECTION_NAME (sec));
}
- g = xmalloc (sizeof (struct group_list));
+ g = (struct group_list *) xmalloc (sizeof (struct group_list));
g->section_index = entry;
g->next = group->root;
group->root = g;
@@ -4874,9 +4896,9 @@ process_relocs (FILE * file)
{
strsec = section_headers + symsec->sh_link;
- strtab = get_data (NULL, file, strsec->sh_offset,
- 1, strsec->sh_size,
- _("string table"));
+ strtab = (char *) get_data (NULL, file, strsec->sh_offset,
+ 1, strsec->sh_size,
+ _("string table"));
strtablen = strtab == NULL ? 0 : strsec->sh_size;
}
@@ -4920,15 +4942,17 @@ struct absaddr
? section_headers [(a).section].sh_addr + (a).offset \
: (a).offset)
+struct ia64_unw_table_entry
+ {
+ struct absaddr start;
+ struct absaddr end;
+ struct absaddr info;
+ };
+
struct ia64_unw_aux_info
{
- struct ia64_unw_table_entry
- {
- struct absaddr start;
- struct absaddr end;
- struct absaddr info;
- }
- *table; /* Unwind table. */
+
+ struct ia64_unw_table_entry *table; /* Unwind table. */
unsigned long table_len; /* Length of unwind table. */
unsigned char * info; /* Unwind info. */
unsigned long info_size; /* Size of unwind info. */
@@ -5077,11 +5101,13 @@ slurp_ia64_unwind_table (FILE * file,
/* Second, build the unwind table from the contents of the unwind section: */
size = sec->sh_size;
- table = get_data (NULL, file, sec->sh_offset, 1, size, _("unwind table"));
+ table = (unsigned char *) get_data (NULL, file, sec->sh_offset, 1, size,
+ _("unwind table"));
if (!table)
return 0;
- aux->table = xcmalloc (size / (3 * eh_addr_size), sizeof (aux->table[0]));
+ aux->table = (struct ia64_unw_table_entry *)
+ xcmalloc (size / (3 * eh_addr_size), sizeof (aux->table[0]));
tep = aux->table;
for (tp = table; tp < table + size; ++tep)
{
@@ -5170,8 +5196,9 @@ ia64_process_unwind (FILE * file)
aux.symtab = GET_ELF_SYMBOLS (file, sec);
strsec = section_headers + sec->sh_link;
- aux.strtab = get_data (NULL, file, strsec->sh_offset,
- 1, strsec->sh_size, _("string table"));
+ aux.strtab = (char *) get_data (NULL, file, strsec->sh_offset,
+ 1, strsec->sh_size,
+ _("string table"));
aux.strtab_size = aux.strtab != NULL ? strsec->sh_size : 0;
}
else if (sec->sh_type == SHT_IA_64_UNWIND)
@@ -5253,8 +5280,9 @@ ia64_process_unwind (FILE * file)
{
aux.info_size = sec->sh_size;
aux.info_addr = sec->sh_addr;
- aux.info = get_data (NULL, file, sec->sh_offset, 1, aux.info_size,
- _("unwind info"));
+ aux.info = (unsigned char *) get_data (NULL, file, sec->sh_offset, 1,
+ aux.info_size,
+ _("unwind info"));
printf (_("\nUnwind section "));
@@ -5289,45 +5317,46 @@ ia64_process_unwind (FILE * file)
return 1;
}
+struct hppa_unw_table_entry
+ {
+ struct absaddr start;
+ struct absaddr end;
+ unsigned int Cannot_unwind:1; /* 0 */
+ unsigned int Millicode:1; /* 1 */
+ unsigned int Millicode_save_sr0:1; /* 2 */
+ unsigned int Region_description:2; /* 3..4 */
+ unsigned int reserved1:1; /* 5 */
+ unsigned int Entry_SR:1; /* 6 */
+ unsigned int Entry_FR:4; /* number saved */ /* 7..10 */
+ unsigned int Entry_GR:5; /* number saved */ /* 11..15 */
+ unsigned int Args_stored:1; /* 16 */
+ unsigned int Variable_Frame:1; /* 17 */
+ unsigned int Separate_Package_Body:1; /* 18 */
+ unsigned int Frame_Extension_Millicode:1; /* 19 */
+ unsigned int Stack_Overflow_Check:1; /* 20 */
+ unsigned int Two_Instruction_SP_Increment:1; /* 21 */
+ unsigned int Ada_Region:1; /* 22 */
+ unsigned int cxx_info:1; /* 23 */
+ unsigned int cxx_try_catch:1; /* 24 */
+ unsigned int sched_entry_seq:1; /* 25 */
+ unsigned int reserved2:1; /* 26 */
+ unsigned int Save_SP:1; /* 27 */
+ unsigned int Save_RP:1; /* 28 */
+ unsigned int Save_MRP_in_frame:1; /* 29 */
+ unsigned int extn_ptr_defined:1; /* 30 */
+ unsigned int Cleanup_defined:1; /* 31 */
+
+ unsigned int MPE_XL_interrupt_marker:1; /* 0 */
+ unsigned int HP_UX_interrupt_marker:1; /* 1 */
+ unsigned int Large_frame:1; /* 2 */
+ unsigned int Pseudo_SP_Set:1; /* 3 */
+ unsigned int reserved4:1; /* 4 */
+ unsigned int Total_frame_size:27; /* 5..31 */
+ };
+
struct hppa_unw_aux_info
{
- struct hppa_unw_table_entry
- {
- struct absaddr start;
- struct absaddr end;
- unsigned int Cannot_unwind:1; /* 0 */
- unsigned int Millicode:1; /* 1 */
- unsigned int Millicode_save_sr0:1; /* 2 */
- unsigned int Region_description:2; /* 3..4 */
- unsigned int reserved1:1; /* 5 */
- unsigned int Entry_SR:1; /* 6 */
- unsigned int Entry_FR:4; /* number saved */ /* 7..10 */
- unsigned int Entry_GR:5; /* number saved */ /* 11..15 */
- unsigned int Args_stored:1; /* 16 */
- unsigned int Variable_Frame:1; /* 17 */
- unsigned int Separate_Package_Body:1; /* 18 */
- unsigned int Frame_Extension_Millicode:1; /* 19 */
- unsigned int Stack_Overflow_Check:1; /* 20 */
- unsigned int Two_Instruction_SP_Increment:1; /* 21 */
- unsigned int Ada_Region:1; /* 22 */
- unsigned int cxx_info:1; /* 23 */
- unsigned int cxx_try_catch:1; /* 24 */
- unsigned int sched_entry_seq:1; /* 25 */
- unsigned int reserved2:1; /* 26 */
- unsigned int Save_SP:1; /* 27 */
- unsigned int Save_RP:1; /* 28 */
- unsigned int Save_MRP_in_frame:1; /* 29 */
- unsigned int extn_ptr_defined:1; /* 30 */
- unsigned int Cleanup_defined:1; /* 31 */
-
- unsigned int MPE_XL_interrupt_marker:1; /* 0 */
- unsigned int HP_UX_interrupt_marker:1; /* 1 */
- unsigned int Large_frame:1; /* 2 */
- unsigned int Pseudo_SP_Set:1; /* 3 */
- unsigned int reserved4:1; /* 4 */
- unsigned int Total_frame_size:27; /* 5..31 */
- }
- *table; /* Unwind table. */
+ struct hppa_unw_table_entry *table; /* Unwind table. */
unsigned long table_len; /* Length of unwind table. */
bfd_vma seg_base; /* Starting address of segment. */
Elf_Internal_Sym * symtab; /* The symbol table. */
@@ -5445,7 +5474,8 @@ slurp_hppa_unwind_table (FILE * file,
/* Second, build the unwind table from the contents of the unwind
section. */
size = sec->sh_size;
- table = get_data (NULL, file, sec->sh_offset, 1, size, _("unwind table"));
+ table = (unsigned char *) get_data (NULL, file, sec->sh_offset, 1, size,
+ _("unwind table"));
if (!table)
return 0;
@@ -5453,7 +5483,8 @@ slurp_hppa_unwind_table (FILE * file,
nentries = size / unw_ent_size;
size = unw_ent_size * nentries;
- tep = aux->table = xcmalloc (nentries, sizeof (aux->table[0]));
+ tep = aux->table = (struct hppa_unw_table_entry *)
+ xcmalloc (nentries, sizeof (aux->table[0]));
for (tp = table; tp < table + size; tp += unw_ent_size, ++tep)
{
@@ -5578,8 +5609,9 @@ hppa_process_unwind (FILE * file)
aux.symtab = GET_ELF_SYMBOLS (file, sec);
strsec = section_headers + sec->sh_link;
- aux.strtab = get_data (NULL, file, strsec->sh_offset,
- 1, strsec->sh_size, _("string table"));
+ aux.strtab = (char *) get_data (NULL, file, strsec->sh_offset,
+ 1, strsec->sh_size,
+ _("string table"));
aux.strtab_size = aux.strtab != NULL ? strsec->sh_size : 0;
}
else if (streq (SECTION_NAME (sec), ".PARISC.unwind"))
@@ -5805,8 +5837,8 @@ get_32bit_dynamic_section (FILE * file)
Elf32_External_Dyn * ext;
Elf_Internal_Dyn * entry;
- edyn = get_data (NULL, file, dynamic_addr, 1, dynamic_size,
- _("dynamic section"));
+ edyn = (Elf32_External_Dyn *) get_data (NULL, file, dynamic_addr, 1,
+ dynamic_size, _("dynamic section"));
if (!edyn)
return 0;
@@ -5822,7 +5854,8 @@ get_32bit_dynamic_section (FILE * file)
break;
}
- dynamic_section = cmalloc (dynamic_nent, sizeof (* entry));
+ dynamic_section = (Elf_Internal_Dyn *) cmalloc (dynamic_nent,
+ sizeof (* entry));
if (dynamic_section == NULL)
{
error (_("Out of memory\n"));
@@ -5850,8 +5883,8 @@ get_64bit_dynamic_section (FILE * file)
Elf64_External_Dyn * ext;
Elf_Internal_Dyn * entry;
- edyn = get_data (NULL, file, dynamic_addr, 1, dynamic_size,
- _("dynamic section"));
+ edyn = (Elf64_External_Dyn *) get_data (NULL, file, dynamic_addr, 1,
+ dynamic_size, _("dynamic section"));
if (!edyn)
return 0;
@@ -5867,7 +5900,8 @@ get_64bit_dynamic_section (FILE * file)
break;
}
- dynamic_section = cmalloc (dynamic_nent, sizeof (* entry));
+ dynamic_section = (Elf_Internal_Dyn *) cmalloc (dynamic_nent,
+ sizeof (* entry));
if (dynamic_section == NULL)
{
error (_("Out of memory\n"));
@@ -6025,8 +6059,9 @@ process_dynamic_section (FILE * file)
continue;
}
- dynamic_strings = get_data (NULL, file, offset, 1, str_tab_len,
- _("dynamic string table"));
+ dynamic_strings = (char *) get_data (NULL, file, offset, 1,
+ str_tab_len,
+ _("dynamic string table"));
dynamic_strings_length = str_tab_len;
break;
}
@@ -6061,12 +6096,13 @@ process_dynamic_section (FILE * file)
Elf_Internal_Syminfo * syminfo;
/* There is a syminfo section. Read the data. */
- extsyminfo = get_data (NULL, file, dynamic_syminfo_offset, 1,
- syminsz, _("symbol information"));
+ extsyminfo = (Elf_External_Syminfo *)
+ get_data (NULL, file, dynamic_syminfo_offset, 1, syminsz,
+ _("symbol information"));
if (!extsyminfo)
return 0;
- dynamic_syminfo = malloc (syminsz);
+ dynamic_syminfo = (Elf_Internal_Syminfo *) malloc (syminsz);
if (dynamic_syminfo == NULL)
{
error (_("Out of memory\n"));
@@ -6553,9 +6589,9 @@ process_version_sections (FILE * file)
? SECTION_NAME (section_headers + section->sh_link)
: "<corrupt>");
- edefs = get_data (NULL, file, section->sh_offset, 1,
- section->sh_size,
- _("version definition section"));
+ edefs = (Elf_External_Verdef *)
+ get_data (NULL, file, section->sh_offset, 1,section->sh_size,
+ _("version definition section"));
endbuf = (char *) edefs + section->sh_size;
if (!edefs)
break;
@@ -6655,9 +6691,10 @@ process_version_sections (FILE * file)
? SECTION_NAME (section_headers + section->sh_link)
: "<corrupt>");
- eneed = get_data (NULL, file, section->sh_offset, 1,
- section->sh_size,
- _("version need section"));
+ eneed = (Elf_External_Verneed *) get_data (NULL, file,
+ section->sh_offset, 1,
+ section->sh_size,
+ _("version need section"));
endbuf = (char *) eneed + section->sh_size;
if (!eneed)
break;
@@ -6760,8 +6797,9 @@ process_version_sections (FILE * file)
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"));
+ strtab = (char *) get_data (NULL, file, string_sec->sh_offset, 1,
+ string_sec->sh_size,
+ _("version string table"));
if (!strtab)
break;
@@ -6777,15 +6815,16 @@ process_version_sections (FILE * file)
off = offset_from_vma (file,
version_info[DT_VERSIONTAGIDX (DT_VERSYM)],
total * sizeof (short));
- edata = get_data (NULL, file, off, total, sizeof (short),
- _("version symbol data"));
+ edata = (unsigned char *) get_data (NULL, file, off, total,
+ sizeof (short),
+ _("version symbol data"));
if (!edata)
{
free (strtab);
break;
}
- data = cmalloc (total, sizeof (short));
+ data = (short unsigned int *) cmalloc (total, sizeof (short));
for (cnt = total; cnt --;)
data[cnt] = byte_get (edata + cnt * sizeof (short),
@@ -7138,7 +7177,7 @@ get_dynamic_data (FILE * file, unsigned int number, unsigned int ent_size)
unsigned char * e_data;
bfd_vma * i_data;
- e_data = cmalloc (number, ent_size);
+ e_data = (unsigned char *) cmalloc (number, ent_size);
if (e_data == NULL)
{
@@ -7152,7 +7191,7 @@ get_dynamic_data (FILE * file, unsigned int number, unsigned int ent_size)
return NULL;
}
- i_data = cmalloc (number, sizeof (*i_data));
+ i_data = (bfd_vma *) cmalloc (number, sizeof (*i_data));
if (i_data == NULL)
{
@@ -7475,8 +7514,9 @@ process_symbol_table (FILE * file)
string_sec = section_headers + section->sh_link;
- strtab = get_data (NULL, file, string_sec->sh_offset,
- 1, string_sec->sh_size, _("string table"));
+ strtab = (char *) get_data (NULL, file, string_sec->sh_offset,
+ 1, string_sec->sh_size,
+ _("string table"));
strtab_size = strtab != NULL ? string_sec->sh_size : 0;
}
@@ -7663,7 +7703,7 @@ process_symbol_table (FILE * file)
(unsigned long) nbuckets);
printf (_(" Length Number %% of total Coverage\n"));
- lengths = calloc (nbuckets, sizeof (*lengths));
+ lengths = (unsigned long *) calloc (nbuckets, sizeof (*lengths));
if (lengths == NULL)
{
error (_("Out of memory\n"));
@@ -7679,7 +7719,7 @@ process_symbol_table (FILE * file)
}
}
- counts = calloc (maxlength + 1, sizeof (*counts));
+ counts = (unsigned long *) calloc (maxlength + 1, sizeof (*counts));
if (counts == NULL)
{
error (_("Out of memory\n"));
@@ -7722,7 +7762,7 @@ process_symbol_table (FILE * file)
unsigned long nzero_counts = 0;
unsigned long nsyms = 0;
- lengths = calloc (ngnubuckets, sizeof (*lengths));
+ lengths = (unsigned long *) calloc (ngnubuckets, sizeof (*lengths));
if (lengths == NULL)
{
error (_("Out of memory\n"));
@@ -7747,7 +7787,7 @@ process_symbol_table (FILE * file)
nsyms += length;
}
- counts = calloc (maxlength + 1, sizeof (*counts));
+ counts = (unsigned long *) calloc (maxlength + 1, sizeof (*counts));
if (counts == NULL)
{
error (_("Out of memory\n"));
@@ -8287,14 +8327,14 @@ apply_relocations (void * file,
if (is_rela)
{
- if (!slurp_rela_relocs (file, relsec->sh_offset, relsec->sh_size,
- & relocs, & num_relocs))
+ if (!slurp_rela_relocs ((FILE *) 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))
+ if (!slurp_rel_relocs ((FILE *) file, relsec->sh_offset,
+ relsec->sh_size, & relocs, & num_relocs))
return;
}
@@ -8303,7 +8343,7 @@ apply_relocations (void * file,
is_rela = FALSE;
symsec = section_headers + relsec->sh_link;
- symtab = GET_ELF_SYMBOLS (file, symsec);
+ symtab = GET_ELF_SYMBOLS ((FILE *) file, symsec);
for (rp = relocs; rp < relocs + num_relocs; ++rp)
{
@@ -8430,8 +8470,8 @@ get_section_contents (Elf_Internal_Shdr * section, FILE * file)
return NULL;
}
- return get_data (NULL, file, section->sh_offset, 1, num_bytes,
- _("section contents"));
+ return (char *) get_data (NULL, file, section->sh_offset, 1, num_bytes,
+ _("section contents"));
}
@@ -8638,7 +8678,7 @@ uncompress_section_contents (unsigned char ** buffer, dwarf_size_type * size)
strm.avail_in = compressed_size - header_size;
strm.next_in = (Bytef *) compressed_buffer + header_size;
strm.avail_out = uncompressed_size;
- uncompressed_buffer = xmalloc (uncompressed_size);
+ uncompressed_buffer = (unsigned char *) xmalloc (uncompressed_size);
rc = inflateInit (& strm);
while (strm.avail_in > 0)
@@ -8685,8 +8725,9 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
snprintf (buf, sizeof (buf), _("%s section data"), section->name);
section->address = sec->sh_addr;
section->size = sec->sh_size;
- section->start = get_data (NULL, file, sec->sh_offset, 1,
- sec->sh_size, buf);
+ section->start = (unsigned char *) get_data (NULL, (FILE *) file,
+ sec->sh_offset, 1,
+ sec->sh_size, buf);
if (section->start == NULL)
return 0;
@@ -8695,7 +8736,7 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
return 0;
if (debug_displays [debug].relocate)
- apply_relocations (file, sec, section->start);
+ apply_relocations ((FILE *) file, sec, section->start);
return 1;
}
@@ -8719,7 +8760,7 @@ load_debug_section (enum dwarf_section_display_enum debug, void * file)
if (sec == NULL)
return 0;
- return load_specific_debug_section (debug, sec, file);
+ return load_specific_debug_section (debug, sec, (FILE *) file);
}
void
@@ -8742,7 +8783,7 @@ display_debug_section (Elf_Internal_Shdr * section, FILE * file)
char * name = SECTION_NAME (section);
bfd_size_type length;
int result = 1;
- enum dwarf_section_display_enum i;
+ int i;
length = section->sh_size;
if (length == 0)
@@ -8772,18 +8813,19 @@ display_debug_section (Elf_Internal_Shdr * section, FILE * file)
int secondary = (section != find_section (name));
if (secondary)
- free_debug_section (i);
+ free_debug_section ((enum dwarf_section_display_enum) i);
if (streq (debug_displays[i].section.uncompressed_name, name))
sec->name = sec->uncompressed_name;
else
sec->name = sec->compressed_name;
- if (load_specific_debug_section (i, section, file))
+ if (load_specific_debug_section ((enum dwarf_section_display_enum) i,
+ section, file))
{
result &= debug_displays[i].display (sec, file);
if (secondary || (i != info && i != abbrev))
- free_debug_section (i);
+ free_debug_section ((enum dwarf_section_display_enum) i);
}
break;
@@ -9373,8 +9415,8 @@ process_attributes (FILE * file,
if (sect->sh_type != proc_type && sect->sh_type != SHT_GNU_ATTRIBUTES)
continue;
- contents = get_data (NULL, file, sect->sh_offset, 1, sect->sh_size,
- _("attributes"));
+ contents = (unsigned char *) get_data (NULL, file, sect->sh_offset, 1,
+ sect->sh_size, _("attributes"));
if (contents == NULL)
continue;
@@ -9636,9 +9678,10 @@ process_mips_specific (FILE * file)
Elf32_External_Lib * elib;
size_t cnt;
- elib = get_data (NULL, file, liblist_offset,
- liblistno, sizeof (Elf32_External_Lib),
- _("liblist"));
+ elib = (Elf32_External_Lib *) get_data (NULL, file, liblist_offset,
+ liblistno,
+ sizeof (Elf32_External_Lib),
+ _("liblist"));
if (elib)
{
printf ("\nSection '.liblist' contains %lu entries:\n",
@@ -9724,11 +9767,12 @@ process_mips_specific (FILE * file)
while (sect->sh_type != SHT_MIPS_OPTIONS)
++sect;
- eopt = get_data (NULL, file, options_offset, 1, sect->sh_size,
- _("options"));
+ eopt = (Elf_External_Options *) get_data (NULL, file, options_offset, 1,
+ sect->sh_size, _("options"));
if (eopt)
{
- iopt = cmalloc ((sect->sh_size / sizeof (eopt)), sizeof (* iopt));
+ iopt = (Elf_Internal_Options *)
+ cmalloc ((sect->sh_size / sizeof (eopt)), sizeof (* iopt));
if (iopt == NULL)
{
error (_("Out of memory\n"));
@@ -9920,7 +9964,7 @@ process_mips_specific (FILE * file)
return 0;
}
- iconf = cmalloc (conflictsno, sizeof (* iconf));
+ iconf = (Elf32_Conflict *) cmalloc (conflictsno, sizeof (* iconf));
if (iconf == NULL)
{
error (_("Out of memory\n"));
@@ -9931,8 +9975,9 @@ process_mips_specific (FILE * file)
{
Elf32_External_Conflict * econf32;
- econf32 = get_data (NULL, file, conflicts_offset,
- conflictsno, sizeof (* econf32), _("conflict"));
+ econf32 = (Elf32_External_Conflict *)
+ get_data (NULL, file, conflicts_offset, conflictsno,
+ sizeof (* econf32), _("conflict"));
if (!econf32)
return 0;
@@ -9945,8 +9990,9 @@ process_mips_specific (FILE * file)
{
Elf64_External_Conflict * econf64;
- econf64 = get_data (NULL, file, conflicts_offset,
- conflictsno, sizeof (* econf64), _("conflict"));
+ econf64 = (Elf64_External_Conflict *)
+ get_data (NULL, file, conflicts_offset, conflictsno,
+ sizeof (* econf64), _("conflict"));
if (!econf64)
return 0;
@@ -9990,7 +10036,8 @@ process_mips_specific (FILE * file)
global_end = local_end + (symtabno - gotsym) * addr_size;
offset = offset_from_vma (file, pltgot, global_end - pltgot);
- data = get_data (NULL, file, offset, global_end - pltgot, 1, _("GOT"));
+ data = (unsigned char *) get_data (NULL, file, offset,
+ global_end - pltgot, 1, _("GOT"));
printf (_("\nPrimary GOT:\n"));
printf (_(" Canonical gp value: "));
print_vma (pltgot + 0x7ff0, LONG_HEX);
@@ -10085,7 +10132,8 @@ process_mips_specific (FILE * file)
end = mips_pltgot + (2 + count) * addr_size;
offset = offset_from_vma (file, mips_pltgot, end - mips_pltgot);
- data = get_data (NULL, file, offset, end - mips_pltgot, 1, _("PLT GOT"));
+ data = (unsigned char *) get_data (NULL, file, offset, end - mips_pltgot,
+ 1, _("PLT GOT"));
printf (_("\nPLT GOT:\n\n"));
printf (_(" Reserved entries:\n"));
printf (_(" %*s %*s Purpose\n"),
@@ -10153,15 +10201,17 @@ process_gnu_liblist (FILE * file)
if (section->sh_link >= elf_header.e_shnum)
break;
- elib = get_data (NULL, file, section->sh_offset, 1, section->sh_size,
- _("liblist"));
+ elib = (Elf32_External_Lib *)
+ get_data (NULL, file, section->sh_offset, 1, section->sh_size,
+ _("liblist"));
if (elib == NULL)
break;
string_sec = section_headers + section->sh_link;
- strtab = get_data (NULL, file, string_sec->sh_offset, 1,
- string_sec->sh_size, _("liblist string table"));
+ strtab = (char *) get_data (NULL, file, string_sec->sh_offset, 1,
+ string_sec->sh_size,
+ _("liblist string table"));
strtab_size = string_sec->sh_size;
if (strtab == NULL
@@ -10405,7 +10455,8 @@ process_corefile_note_segment (FILE * file, bfd_vma offset, bfd_vma length)
if (length <= 0)
return 0;
- pnotes = get_data (NULL, file, offset, 1, length, _("notes"));
+ pnotes = (Elf_External_Note *) get_data (NULL, file, offset, 1, length,
+ _("notes"));
if (!pnotes)
return 0;
@@ -10447,7 +10498,7 @@ process_corefile_note_segment (FILE * file, bfd_vma offset, bfd_vma length)
namesz. */
if (inote.namedata[inote.namesz] != '\0')
{
- temp = malloc (inote.namesz + 1);
+ temp = (char *) malloc (inote.namesz + 1);
if (temp == NULL)
{
@@ -10822,7 +10873,7 @@ adjust_relative_path (char * file_name, char * name, int name_len)
archive is located. */
if (IS_ABSOLUTE_PATH (name) || base_name == file_name)
{
- member_file_name = malloc (name_len + 1);
+ member_file_name = (char *) malloc (name_len + 1);
if (member_file_name == NULL)
{
error (_("Out of memory\n"));
@@ -10836,7 +10887,7 @@ adjust_relative_path (char * file_name, char * name, int name_len)
/* Concatenate the path components of the archive file name
to the relative path name from the extended name table. */
size_t prefix_len = base_name - file_name;
- member_file_name = malloc (prefix_len + name_len + 1);
+ member_file_name = (char *) malloc (prefix_len + name_len + 1);
if (member_file_name == NULL)
{
error (_("Out of memory\n"));
@@ -10946,7 +10997,8 @@ setup_archive (struct archive_info * arch, char * file_name, FILE * file,
file_name, arch->index_num);
return 1;
}
- index_buffer = malloc (arch->index_num * SIZEOF_AR_INDEX_NUMBERS);
+ index_buffer = (unsigned char *)
+ malloc (arch->index_num * SIZEOF_AR_INDEX_NUMBERS);
if (index_buffer == NULL)
{
error (_("Out of memory whilst trying to read archive symbol index\n"));
@@ -10962,7 +11014,8 @@ setup_archive (struct archive_info * arch, char * file_name, FILE * file,
size -= arch->index_num * SIZEOF_AR_INDEX_NUMBERS;
/* Convert the index numbers into the host's numeric format. */
- arch->index_array = malloc (arch->index_num * sizeof (* arch->index_array));
+ arch->index_array = (long unsigned int *)
+ malloc (arch->index_num * sizeof (* arch->index_array));
if (arch->index_array == NULL)
{
free (index_buffer);
@@ -10981,7 +11034,7 @@ setup_archive (struct archive_info * arch, char * file_name, FILE * file,
error (_("%s: the archive has an index but no symbols\n"), file_name);
return 1;
}
- arch->sym_table = malloc (size);
+ arch->sym_table = (char *) malloc (size);
arch->sym_size = size;
if (arch->sym_table == NULL)
{
@@ -11023,7 +11076,7 @@ setup_archive (struct archive_info * arch, char * file_name, FILE * file,
arch->longnames_size = strtoul (arch->arhdr.ar_size, NULL, 10);
arch->next_arhdr_offset += sizeof arch->arhdr + arch->longnames_size;
- arch->longnames = malloc (arch->longnames_size);
+ arch->longnames = (char *) malloc (arch->longnames_size);
if (arch->longnames == NULL)
{
error (_("Out of memory reading long symbol names in archive\n"));
@@ -11195,7 +11248,7 @@ make_qualified_name (struct archive_info * arch,
if (arch->is_thin_archive && arch->nested_member_origin != 0)
len += strlen (nested_arch->file_name) + 2;
- name = malloc (len);
+ name = (char *) malloc (len);
if (name == NULL)
{
error (_("Out of memory\n"));
@@ -11530,7 +11583,8 @@ main (int argc, char ** argv)
if (num_dump_sects > 0)
{
/* Make a copy of the dump_sects array. */
- cmdline_dump_sects = malloc (num_dump_sects * sizeof (* dump_sects));
+ cmdline_dump_sects = (dump_type *)
+ malloc (num_dump_sects * sizeof (* dump_sects));
if (cmdline_dump_sects == NULL)
error (_("Out of memory allocating dump request table.\n"));
else