All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Redfearn <matt.redfearn@imgtec.com>
To: Harvey Hunt <harvey.hunt@imgtec.com>, <ralf@linux-mips.org>
Cc: <linux-mips@linux-mips.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] MIPS: tools: Fix relocs tool compiler warnings
Date: Fri, 17 Jun 2016 09:45:12 +0100	[thread overview]
Message-ID: <5763B898.7040502@imgtec.com> (raw)
In-Reply-To: <20160616153539.10600-1-harvey.hunt@imgtec.com>



On 16/06/16 16:35, Harvey Hunt wrote:
> When using clang as HOSTCC, the following warnings appear:
>
> In file included from arch/mips/boot/tools/relocs_64.c:27:0:
> arch/mips/boot/tools/relocs.c: In function ‘read_relocs’:
> arch/mips/boot/tools/relocs.c:397:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
>      ELF_R_SYM(rel->r_info) = elf32_to_cpu(ELF_R_SYM(rel->r_info));
>      ^~~~~~~~~
> arch/mips/boot/tools/relocs.c:397:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
> arch/mips/boot/tools/relocs.c: In function ‘walk_relocs’:
> arch/mips/boot/tools/relocs.c:491:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
>      Elf_Sym *sym = &sh_symtab[ELF_R_SYM(rel->r_info)];
>      ^~~~~~~
> arch/mips/boot/tools/relocs.c: In function ‘do_reloc’:
> arch/mips/boot/tools/relocs.c:502:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
>    unsigned r_type = ELF_R_TYPE(rel->r_info);
>    ^~~~~~~~
> arch/mips/boot/tools/relocs.c: In function ‘do_reloc_info’:
> arch/mips/boot/tools/relocs.c:641:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
>     rel_type(ELF_R_TYPE(rel->r_info)),
>     ^~~~~~~~
>
> Fix them by making Elf64_Mips_Rela a union
>
> Signed-off-by: Harvey Hunt <harvey.hunt@imgtec.com>
> Cc: Matt Redfearn <matt.redfearn@imgtec.com>
> Cc: linux-mips@linux-mips.org
> Cc: linux-kernel@vger.kernel.org
> ---
>   arch/mips/boot/tools/relocs_64.c | 19 +++++++++++--------
>   1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/arch/mips/boot/tools/relocs_64.c b/arch/mips/boot/tools/relocs_64.c
> index b671b5e..06066e6a 100644
> --- a/arch/mips/boot/tools/relocs_64.c
> +++ b/arch/mips/boot/tools/relocs_64.c
> @@ -9,17 +9,20 @@
>   
>   typedef uint8_t Elf64_Byte;
>   
> -typedef struct {
> -	Elf64_Word r_sym;	/* Symbol index.  */
> -	Elf64_Byte r_ssym;	/* Special symbol.  */
> -	Elf64_Byte r_type3;	/* Third relocation.  */
> -	Elf64_Byte r_type2;	/* Second relocation.  */
> -	Elf64_Byte r_type;	/* First relocation.  */
> +typedef union {
> +	struct {
> +		Elf64_Word r_sym;	/* Symbol index.  */
> +		Elf64_Byte r_ssym;	/* Special symbol.  */
> +		Elf64_Byte r_type3;	/* Third relocation.  */
> +		Elf64_Byte r_type2;	/* Second relocation.  */
> +		Elf64_Byte r_type;	/* First relocation.  */
> +	} fields;
> +	Elf64_Xword unused;
>   } Elf64_Mips_Rela;
>   
>   #define ELF_CLASS               ELFCLASS64
> -#define ELF_R_SYM(val)          (((Elf64_Mips_Rela *)(&val))->r_sym)
> -#define ELF_R_TYPE(val)         (((Elf64_Mips_Rela *)(&val))->r_type)
> +#define ELF_R_SYM(val)          (((Elf64_Mips_Rela *)(&val))->fields.r_sym)
> +#define ELF_R_TYPE(val)         (((Elf64_Mips_Rela *)(&val))->fields.r_type)
>   #define ELF_ST_TYPE(o)          ELF64_ST_TYPE(o)
>   #define ELF_ST_BIND(o)          ELF64_ST_BIND(o)
>   #define ELF_ST_VISIBILITY(o)    ELF64_ST_VISIBILITY(o)

Acked-by: Matt Redfearn <matt.redfearn@imgtec.com>

WARNING: multiple messages have this Message-ID (diff)
From: Matt Redfearn <matt.redfearn@imgtec.com>
To: Harvey Hunt <harvey.hunt@imgtec.com>, ralf@linux-mips.org
Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MIPS: tools: Fix relocs tool compiler warnings
Date: Fri, 17 Jun 2016 09:45:12 +0100	[thread overview]
Message-ID: <5763B898.7040502@imgtec.com> (raw)
Message-ID: <20160617084512.8ul4hLyAwHY5EnOAA3KyDcUXaQ9rgtrHWAN3Vuc0JjI@z> (raw)
In-Reply-To: <20160616153539.10600-1-harvey.hunt@imgtec.com>



On 16/06/16 16:35, Harvey Hunt wrote:
> When using clang as HOSTCC, the following warnings appear:
>
> In file included from arch/mips/boot/tools/relocs_64.c:27:0:
> arch/mips/boot/tools/relocs.c: In function ‘read_relocs’:
> arch/mips/boot/tools/relocs.c:397:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
>      ELF_R_SYM(rel->r_info) = elf32_to_cpu(ELF_R_SYM(rel->r_info));
>      ^~~~~~~~~
> arch/mips/boot/tools/relocs.c:397:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
> arch/mips/boot/tools/relocs.c: In function ‘walk_relocs’:
> arch/mips/boot/tools/relocs.c:491:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
>      Elf_Sym *sym = &sh_symtab[ELF_R_SYM(rel->r_info)];
>      ^~~~~~~
> arch/mips/boot/tools/relocs.c: In function ‘do_reloc’:
> arch/mips/boot/tools/relocs.c:502:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
>    unsigned r_type = ELF_R_TYPE(rel->r_info);
>    ^~~~~~~~
> arch/mips/boot/tools/relocs.c: In function ‘do_reloc_info’:
> arch/mips/boot/tools/relocs.c:641:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
>     rel_type(ELF_R_TYPE(rel->r_info)),
>     ^~~~~~~~
>
> Fix them by making Elf64_Mips_Rela a union
>
> Signed-off-by: Harvey Hunt <harvey.hunt@imgtec.com>
> Cc: Matt Redfearn <matt.redfearn@imgtec.com>
> Cc: linux-mips@linux-mips.org
> Cc: linux-kernel@vger.kernel.org
> ---
>   arch/mips/boot/tools/relocs_64.c | 19 +++++++++++--------
>   1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/arch/mips/boot/tools/relocs_64.c b/arch/mips/boot/tools/relocs_64.c
> index b671b5e..06066e6a 100644
> --- a/arch/mips/boot/tools/relocs_64.c
> +++ b/arch/mips/boot/tools/relocs_64.c
> @@ -9,17 +9,20 @@
>   
>   typedef uint8_t Elf64_Byte;
>   
> -typedef struct {
> -	Elf64_Word r_sym;	/* Symbol index.  */
> -	Elf64_Byte r_ssym;	/* Special symbol.  */
> -	Elf64_Byte r_type3;	/* Third relocation.  */
> -	Elf64_Byte r_type2;	/* Second relocation.  */
> -	Elf64_Byte r_type;	/* First relocation.  */
> +typedef union {
> +	struct {
> +		Elf64_Word r_sym;	/* Symbol index.  */
> +		Elf64_Byte r_ssym;	/* Special symbol.  */
> +		Elf64_Byte r_type3;	/* Third relocation.  */
> +		Elf64_Byte r_type2;	/* Second relocation.  */
> +		Elf64_Byte r_type;	/* First relocation.  */
> +	} fields;
> +	Elf64_Xword unused;
>   } Elf64_Mips_Rela;
>   
>   #define ELF_CLASS               ELFCLASS64
> -#define ELF_R_SYM(val)          (((Elf64_Mips_Rela *)(&val))->r_sym)
> -#define ELF_R_TYPE(val)         (((Elf64_Mips_Rela *)(&val))->r_type)
> +#define ELF_R_SYM(val)          (((Elf64_Mips_Rela *)(&val))->fields.r_sym)
> +#define ELF_R_TYPE(val)         (((Elf64_Mips_Rela *)(&val))->fields.r_type)
>   #define ELF_ST_TYPE(o)          ELF64_ST_TYPE(o)
>   #define ELF_ST_BIND(o)          ELF64_ST_BIND(o)
>   #define ELF_ST_VISIBILITY(o)    ELF64_ST_VISIBILITY(o)

Acked-by: Matt Redfearn <matt.redfearn@imgtec.com>

  reply	other threads:[~2016-06-17  8:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 15:35 [PATCH] MIPS: tools: Fix relocs tool compiler warnings Harvey Hunt
2016-06-16 15:35 ` Harvey Hunt
2016-06-17  8:45 ` Matt Redfearn [this message]
2016-06-17  8:45   ` Matt Redfearn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5763B898.7040502@imgtec.com \
    --to=matt.redfearn@imgtec.com \
    --cc=harvey.hunt@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.