lkml.org 
[lkml]   [2016]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] MIPS: Differentiate between 32 and 64 bit ELF header
On Fri, 29 Jan 2016, Daniel Wagner wrote:

> Depending on the configuration either the 32 or 64 bit version of
> elf_check_arch() is defined. parse_crash_elf32_headers() does
> some basic verification of the ELF header via elf_check_arch().
> parse_crash_elf64_headers() does it via vmcore_elf64_check_arch()
> which expands to the same elf_check_check().
>
> 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) ||
> ^
>
> Since the MIPS ELF header for 32 bit and 64 bit differ we need
> to check accordingly.

I fail to see how it can work as it stands given that `elf_check_arch' is
called from the same source file both on a pointer to `Elf32_Ehdr' and one
to `Elf64_Ehdr'. However the MIPS implementations of `elf_check_arch'
only use an auxiliary variable to avoid multiple evaluation of a macro
argument and therefore instead I recommend the use of the usual approach
taken in such a situation within a statement expression, that is to
declare the variable with `typeof' rather than an explicit type. As an
upside this will minimise code disruption as well.

For consistency I suggest making the same change to the `elf_check_arch'
definitions in arch/mips/kernel/binfmt_elf*.c as well.

Maciej

\
 
 \ /
  Last update: 2016-02-01 02:01    [W:0.133 / U:1.464 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site