Re: [PATCH v4 2/2] mips: Differentiate between 32 and 64 bit ELF header

From: Ralf Baechle
Date: Thu Feb 11 2016 - 06:18:37 EST


On Wed, Feb 10, 2016 at 10:21:21AM +0100, Daniel Wagner wrote:

> Depending on the configuration either the 32 or 64 bit version of
> elf_check_arch() is defined. parse_crash_elf{32|64}_headers() does
> some basic verification of the ELF header via
> vmcore_elf{32|64}_check_arch() which happen to map to elf_check_arch().
> Since the implementation 32 and 64 bit version of elf_check_arch()
> differ, we use the wrong type:
>
> In file included from include/linux/elf.h:4:0,
> from fs/proc/vmcore.c:13:
> fs/proc/vmcore.c: In function 'parse_crash_elf64_headers':
> >> arch/mips/include/asm/elf.h:228:23: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
> struct elfhdr *__h = (hdr); \
> ^
> include/linux/crash_dump.h:41:37: note: in expansion of macro 'elf_check_arch'
> #define vmcore_elf64_check_arch(x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x))
> ^
> fs/proc/vmcore.c:1015:4: note: in expansion of macro 'vmcore_elf64_check_arch'
> !vmcore_elf64_check_arch(&ehdr) ||
> ^
>
> Therefore, we rather define vmcore_elf{32|64}_check_arch() as a
> basic machine check and use it also in binfm_elf?32.c as well.
>
> Signed-off-by: Daniel Wagner <daniel.wagner@xxxxxxxxxxxx>
> Suggested-by: Maciej W. Rozycki <macro@xxxxxxxxxx>
> Reviewed-by: Maciej W. Rozycki <macro@xxxxxxxxxx>
> Reported-by: Fengguang Wu <fengguang.wu@xxxxxxxxx>

Thanks, applied.

I'm getting a less spectacular warning from gcc 5.2:

CC fs/proc/vmcore.o
fs/proc/vmcore.c: In function âparse_crash_elf64_headersâ:
fs/proc/vmcore.c:939:47: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]

Ralf