This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Fix up gcc4.1 aliasing warnings
- From: Daniel Jacobowitz <drow at false dot org>
- To: binutils at sourceware dot org
- Date: Thu, 6 Oct 2005 15:23:28 -0400
- Subject: Fix up gcc4.1 aliasing warnings
DJ got a bunch of these last week, but many more platforms were affected.
This is enough for --enable-targets=all to build using GCC HEAD and -Werror.
Committed.
--
Daniel Jacobowitz
CodeSourcery, LLC
2005-10-06 Daniel Jacobowitz <dan@codesourcery.com>
* elf32-arm.c (elf32_arm_check_relocs): Avoid aliasing warnings from
GCC.
(elf32_arm_size_dynamic_sections): Likewise.
* ecofflink.c (bfd_ecoff_debug_one_external): Likewise.
* elf32-hppa.c (elf32_hppa_check_relocs): Likewise.
* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
* elf32-m68k.c (elf_m68k_check_relocs): Likewise.
* elf32-ppc.c (ppc_elf_check_relocs): Likewise.
* elf32-s390.c (elf_s390_check_relocs): Likewise.
(elf_s390_size_dynamic_sections): Likewise.
* elf32-sh.c (sh_elf_check_relocs): Likewise.
* elf64-ppc.c (ppc64_elf_check_relocs, dec_dynrel_count)
(ppc64_elf_size_dynamic_sections): Likewise.
* elf64-s390.c (elf_s390_check_relocs): Likewise.
(elf_s390_size_dynamic_sections): Likewise.
* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
(_bfd_sparc_elf_size_dynamic_sections): Likewise.
* ieee.c (ieee_slurp_section_data): Likewise.
* oasys.c (oasys_slurp_section_data): Likewise.
2005-10-06 Daniel Jacobowitz <dan@codesourcery.com>
* ppc-dis.c (struct dis_private): Remove.
(powerpc_dialect): Avoid aliasing warnings.
(print_insn_big_powerpc, print_insn_little_powerpc): Likewise.
Index: src/bfd/elf32-arm.c
===================================================================
--- src.orig/bfd/elf32-arm.c 2005-09-09 09:10:01.000000000 -0400
+++ src/bfd/elf32-arm.c 2005-10-05 21:03:38.000000000 -0400
@@ -5118,13 +5118,15 @@ elf32_arm_check_relocs (bfd *abfd, struc
easily. Oh well. */
asection *s;
+ void *vpp;
+
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
sec, r_symndx);
if (s == NULL)
return FALSE;
- head = ((struct elf32_arm_relocs_copied **)
- &elf_section_data (s)->local_dynrel);
+ vpp = &elf_section_data (s)->local_dynrel;
+ head = (struct elf32_arm_relocs_copied **) vpp;
}
p = *head;
@@ -5785,10 +5787,7 @@ elf32_arm_size_dynamic_sections (bfd * o
{
struct elf32_arm_relocs_copied *p;
- for (p = *((struct elf32_arm_relocs_copied **)
- &elf_section_data (s)->local_dynrel);
- p != NULL;
- p = p->next)
+ for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
{
if (!bfd_is_abs_section (p->section)
&& bfd_is_abs_section (p->section->output_section))
Index: src/bfd/ecofflink.c
===================================================================
--- src.orig/bfd/ecofflink.c 2005-09-30 16:06:31.000000000 -0400
+++ src/bfd/ecofflink.c 2005-10-06 14:23:16.000000000 -0400
@@ -1338,10 +1338,14 @@ bfd_ecoff_debug_one_external (abfd, debu
- (char *) debug->external_ext)
< (symhdr->iextMax + 1) * external_ext_size)
{
- if (! ecoff_add_bytes ((char **) &debug->external_ext,
- (char **) &debug->external_ext_end,
+ char *external_ext = debug->external_ext;
+ char *external_ext_end = debug->external_ext_end;
+ if (! ecoff_add_bytes ((char **) &external_ext,
+ (char **) &external_ext_end,
(symhdr->iextMax + 1) * (size_t) external_ext_size))
return FALSE;
+ debug->external_ext = external_ext;
+ debug->external_ext_end = external_ext_end;
}
esym->asym.iss = symhdr->issExtMax;
Index: src/bfd/elf32-hppa.c
===================================================================
--- src.orig/bfd/elf32-hppa.c 2005-08-17 21:28:22.000000000 -0400
+++ src/bfd/elf32-hppa.c 2005-10-06 14:27:59.000000000 -0400
@@ -1446,13 +1446,15 @@ elf32_hppa_check_relocs (bfd *abfd,
easily. Oh well. */
asection *sr;
+ void *vpp;
+
sr = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
sec, r_symndx);
if (sr == NULL)
return FALSE;
- hdh_head = ((struct elf32_hppa_dyn_reloc_entry **)
- &elf_section_data (sr)->local_dynrel);
+ vpp = &elf_section_data (sr)->local_dynrel;
+ hdh_head = (struct elf32_hppa_dyn_reloc_entry **) vpp;
}
hdh_p = *hdh_head;
Index: src/bfd/elf32-m32r.c
===================================================================
--- src.orig/bfd/elf32-m32r.c 2005-08-24 22:32:09.000000000 -0400
+++ src/bfd/elf32-m32r.c 2005-10-06 14:28:58.000000000 -0400
@@ -3993,6 +3993,7 @@ m32r_elf_check_relocs (bfd *abfd,
else
{
asection *s;
+ void *vpp;
/* Track dynamic relocs needed for local syms too. */
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
@@ -4000,8 +4001,8 @@ m32r_elf_check_relocs (bfd *abfd,
if (s == NULL)
return FALSE;
- head = ((struct elf_m32r_dyn_relocs **)
- &elf_section_data (s)->local_dynrel);
+ vpp = &elf_section_data (s)->local_dynrel;
+ head = (struct elf_m32r_dyn_relocs **) vpp;
}
p = *head;
Index: src/bfd/elf32-m68k.c
===================================================================
--- src.orig/bfd/elf32-m68k.c 2005-08-24 22:32:09.000000000 -0400
+++ src/bfd/elf32-m68k.c 2005-10-06 14:29:32.000000000 -0400
@@ -745,14 +745,16 @@ elf_m68k_check_relocs (abfd, info, sec,
else
{
asection *s;
+ void *vpp;
+
s = (bfd_section_from_r_symndx
(abfd, &elf_m68k_hash_table (info)->sym_sec,
sec, r_symndx));
if (s == NULL)
return FALSE;
- head = ((struct elf_m68k_pcrel_relocs_copied **)
- &elf_section_data (s)->local_dynrel);
+ vpp = &elf_section_data (s)->local_dynrel;
+ head = (struct elf_m68k_pcrel_relocs_copied **) vpp;
}
for (p = *head; p != NULL; p = p->next)
Index: src/bfd/elf32-ppc.c
===================================================================
--- src.orig/bfd/elf32-ppc.c 2005-08-17 21:28:23.000000000 -0400
+++ src/bfd/elf32-ppc.c 2005-10-06 14:30:13.000000000 -0400
@@ -3469,13 +3469,15 @@ ppc_elf_check_relocs (bfd *abfd,
easily. Oh well. */
asection *s;
+ void *vpp;
+
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
sec, r_symndx);
if (s == NULL)
return FALSE;
- head = ((struct ppc_elf_dyn_relocs **)
- &elf_section_data (s)->local_dynrel);
+ vpp = &elf_section_data (s)->local_dynrel;
+ head = (struct ppc_elf_dyn_relocs **) vpp;
}
p = *head;
Index: src/bfd/elf32-s390.c
===================================================================
--- src.orig/bfd/elf32-s390.c 2005-08-24 22:32:10.000000000 -0400
+++ src/bfd/elf32-s390.c 2005-10-06 14:32:11.000000000 -0400
@@ -1319,14 +1319,15 @@ elf_s390_check_relocs (abfd, info, sec,
We really need local syms available to do this
easily. Oh well. */
asection *s;
+ void *vpp;
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
sec, r_symndx);
if (s == NULL)
return FALSE;
- head = ((struct elf_s390_dyn_relocs **)
- &elf_section_data (s)->local_dynrel);
+ vpp = &elf_section_data (s)->local_dynrel;
+ head = (struct elf_s390_dyn_relocs **) vpp;
}
p = *head;
@@ -2038,10 +2039,7 @@ elf_s390_size_dynamic_sections (output_b
{
struct elf_s390_dyn_relocs *p;
- for (p = *((struct elf_s390_dyn_relocs **)
- &elf_section_data (s)->local_dynrel);
- p != NULL;
- p = p->next)
+ for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
{
if (!bfd_is_abs_section (p->sec)
&& bfd_is_abs_section (p->sec->output_section))
Index: src/bfd/elf32-sh.c
===================================================================
--- src.orig/bfd/elf32-sh.c 2005-08-25 01:10:22.000000000 -0400
+++ src/bfd/elf32-sh.c 2005-10-06 14:30:38.000000000 -0400
@@ -6565,6 +6565,7 @@ sh_elf_check_relocs (bfd *abfd, struct b
else
{
asection *s;
+ void *vpp;
/* Track dynamic relocs needed for local syms too. */
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
@@ -6572,8 +6573,8 @@ sh_elf_check_relocs (bfd *abfd, struct b
if (s == NULL)
return FALSE;
- head = ((struct elf_sh_dyn_relocs **)
- &elf_section_data (s)->local_dynrel);
+ vpp = &elf_section_data (s)->local_dynrel;
+ head = (struct elf_sh_dyn_relocs **) vpp;
}
p = *head;
Index: src/bfd/elf64-ppc.c
===================================================================
--- src.orig/bfd/elf64-ppc.c 2005-09-19 05:35:26.000000000 -0400
+++ src/bfd/elf64-ppc.c 2005-10-06 14:20:14.000000000 -0400
@@ -4767,13 +4767,15 @@ ppc64_elf_check_relocs (bfd *abfd, struc
easily. Oh well. */
asection *s;
+ void *vpp;
+
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
sec, r_symndx);
if (s == NULL)
return FALSE;
- head = ((struct ppc_dyn_relocs **)
- &elf_section_data (s)->local_dynrel);
+ vpp = &elf_section_data (s)->local_dynrel;
+ head = (struct ppc_dyn_relocs **) vpp;
}
p = *head;
@@ -6119,9 +6121,15 @@ dec_dynrel_count (bfd_vma r_info,
if (h != NULL)
pp = &((struct ppc_link_hash_entry *) h)->dyn_relocs;
else if (sym_sec != NULL)
- pp = (struct ppc_dyn_relocs **) &elf_section_data (sym_sec)->local_dynrel;
+ {
+ void *vpp = &elf_section_data (sym_sec)->local_dynrel;
+ pp = (struct ppc_dyn_relocs **) vpp;
+ }
else
- pp = (struct ppc_dyn_relocs **) &elf_section_data (sec)->local_dynrel;
+ {
+ void *vpp = &elf_section_data (sec)->local_dynrel;
+ pp = (struct ppc_dyn_relocs **) vpp;
+ }
while ((p = *pp) != NULL)
{
@@ -7638,10 +7646,7 @@ ppc64_elf_size_dynamic_sections (bfd *ou
{
struct ppc_dyn_relocs *p;
- for (p = *((struct ppc_dyn_relocs **)
- &elf_section_data (s)->local_dynrel);
- p != NULL;
- p = p->next)
+ for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
{
if (!bfd_is_abs_section (p->sec)
&& bfd_is_abs_section (p->sec->output_section))
Index: src/bfd/elf64-s390.c
===================================================================
--- src.orig/bfd/elf64-s390.c 2005-08-24 22:32:10.000000000 -0400
+++ src/bfd/elf64-s390.c 2005-10-06 11:47:39.000000000 -0400
@@ -1285,13 +1285,15 @@ elf_s390_check_relocs (abfd, info, sec,
easily. Oh well. */
asection *s;
+ void *vpp;
+
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
sec, r_symndx);
if (s == NULL)
return FALSE;
- head = ((struct elf_s390_dyn_relocs **)
- &elf_section_data (s)->local_dynrel);
+ vpp = &elf_section_data (s)->local_dynrel;
+ head = (struct elf_s390_dyn_relocs **) vpp;
}
p = *head;
@@ -2009,10 +2011,7 @@ elf_s390_size_dynamic_sections (output_b
{
struct elf_s390_dyn_relocs *p;
- for (p = *((struct elf_s390_dyn_relocs **)
- &elf_section_data (s)->local_dynrel);
- p != NULL;
- p = p->next)
+ for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
{
if (!bfd_is_abs_section (p->sec)
&& bfd_is_abs_section (p->sec->output_section))
Index: src/bfd/elfxx-mips.c
===================================================================
--- src.orig/bfd/elfxx-mips.c 2005-09-30 16:06:31.000000000 -0400
+++ src/bfd/elfxx-mips.c 2005-10-06 14:23:16.000000000 -0400
@@ -7638,7 +7638,11 @@ _bfd_mips_elf_finish_dynamic_sections (b
break;
case DT_MIPS_TIME_STAMP:
- time ((time_t *) &dyn.d_un.d_val);
+ {
+ time_t t;
+ time (&t);
+ dyn.d_un.d_val = t;
+ }
break;
case DT_MIPS_ICHECKSUM:
Index: src/bfd/elfxx-sparc.c
===================================================================
--- src.orig/bfd/elfxx-sparc.c 2005-08-24 22:32:11.000000000 -0400
+++ src/bfd/elfxx-sparc.c 2005-10-06 14:33:16.000000000 -0400
@@ -1381,13 +1381,15 @@ _bfd_sparc_elf_check_relocs (bfd *abfd,
easily. Oh well. */
asection *s;
+ void *vpp;
+
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
sec, r_symndx);
if (s == NULL)
return FALSE;
- head = ((struct _bfd_sparc_elf_dyn_relocs **)
- &elf_section_data (s)->local_dynrel);
+ vpp = &elf_section_data (s)->local_dynrel;
+ head = (struct _bfd_sparc_elf_dyn_relocs **) vpp;
}
p = *head;
@@ -2071,10 +2073,7 @@ _bfd_sparc_elf_size_dynamic_sections (bf
{
struct _bfd_sparc_elf_dyn_relocs *p;
- for (p = *((struct _bfd_sparc_elf_dyn_relocs **)
- &elf_section_data (s)->local_dynrel);
- p != NULL;
- p = p->next)
+ for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
{
if (!bfd_is_abs_section (p->sec)
&& bfd_is_abs_section (p->sec->output_section))
Index: src/bfd/ieee.c
===================================================================
--- src.orig/bfd/ieee.c 2005-08-17 23:48:26.000000000 -0400
+++ src/bfd/ieee.c 2005-10-06 14:37:02.000000000 -0400
@@ -1666,14 +1666,15 @@ ieee_slurp_section_data (bfd *abfd)
for (s = abfd->sections; s != (asection *) NULL; s = s->next)
{
ieee_per_section_type *per = ieee_per_section (s);
+ arelent **relpp;
if ((s->flags & SEC_DEBUGGING) != 0)
continue;
per->data = bfd_alloc (ieee->h.abfd, s->size);
if (!per->data)
return FALSE;
- per->reloc_tail_ptr =
- (ieee_reloc_type **) & (s->relocation);
+ relpp = &s->relocation;
+ per->reloc_tail_ptr = (ieee_reloc_type **) relpp;
}
while (TRUE)
Index: src/bfd/oasys.c
===================================================================
--- src.orig/bfd/oasys.c 2005-05-23 13:44:55.000000000 -0400
+++ src/bfd/oasys.c 2005-10-06 14:37:59.000000000 -0400
@@ -384,11 +384,13 @@ oasys_slurp_section_data (bfd *const abf
if (! per->initialized)
{
+ arelent **relpp;
+
per->data = bfd_zalloc (abfd, section->size);
if (!per->data)
return FALSE;
- per->reloc_tail_ptr
- = (oasys_reloc_type **) §ion->relocation;
+ relpp = §ion->relocation;
+ per->reloc_tail_ptr = (oasys_reloc_type **) relpp;
per->had_vma = FALSE;
per->initialized = TRUE;
section->reloc_count = 0;
Index: src/opcodes/ppc-dis.c
===================================================================
--- src.orig/opcodes/ppc-dis.c 2005-08-15 11:37:15.000000000 -0400
+++ src/opcodes/ppc-dis.c 2005-10-06 14:58:22.000000000 -0400
@@ -32,11 +32,6 @@ Software Foundation, 51 Franklin Street
static int print_insn_powerpc (bfd_vma, struct disassemble_info *, int, int);
-struct dis_private {
- /* Stash the result of parsing disassembler_options here. */
- int dialect;
-};
-
/* Determine which set of machines to disassemble for. PPC403/601 or
BookE. For convenience, also disassemble instructions supported
by the AltiVec vector unit. */
@@ -90,7 +85,7 @@ powerpc_dialect (struct disassemble_info
dialect |= PPC_OPCODE_64;
}
- ((struct dis_private *) &info->private_data)->dialect = dialect;
+ info->private_data = (char *) 0 + dialect;
return dialect;
}
@@ -99,7 +94,7 @@ powerpc_dialect (struct disassemble_info
int
print_insn_big_powerpc (bfd_vma memaddr, struct disassemble_info *info)
{
- int dialect = ((struct dis_private *) &info->private_data)->dialect;
+ int dialect = (char *) info->private_data - (char *) 0;
return print_insn_powerpc (memaddr, info, 1, dialect);
}
@@ -108,7 +103,7 @@ print_insn_big_powerpc (bfd_vma memaddr,
int
print_insn_little_powerpc (bfd_vma memaddr, struct disassemble_info *info)
{
- int dialect = ((struct dis_private *) &info->private_data)->dialect;
+ int dialect = (char *) info->private_data - (char *) 0;
return print_insn_powerpc (memaddr, info, 0, dialect);
}